pub struct RawSegment { /* private fields */ }Expand description
A segment represents a sequence of operations that can be executed.
Each operation is stored along with its data in the segment’s storage, and can manipulate values on a stack during execution.
Implementations§
Source§impl RawSegment
impl RawSegment
Sourcepub fn new() -> RawSegment
pub fn new() -> RawSegment
Creates a new empty segment.
Sourcepub fn raw0_<F>(&mut self, op: F)
pub fn raw0_<F>(&mut self, op: F)
Pushes a closure that manipulates the stack directly and returns ().
Sourcepub fn raw0<R, F>(&mut self, op: F)
pub fn raw0<R, F>(&mut self, op: F)
Push a closure that manipulates the stack and returns a value R.
Sourcepub fn push_op0<R, F>(&mut self, op: F)where
F: Fn() -> R + 'static,
R: 'static,
pub fn push_op0<R, F>(&mut self, op: F)where
F: Fn() -> R + 'static,
R: 'static,
Pushes a unary operation that takes one argument of type T and returns a value of type R.
Sourcepub fn push_op1<T, R, F>(&mut self, op: F, padding0: bool)where
F: Fn(T) -> R + 'static,
T: 'static,
R: 'static,
pub fn push_op1<T, R, F>(&mut self, op: F, padding0: bool)where
F: Fn(T) -> R + 'static,
T: 'static,
R: 'static,
Pushes a unary operation that takes one argument of type T and returns a value of type R.
Sourcepub fn raw1<T, R, F>(&mut self, op: F, padding0: bool)
pub fn raw1<T, R, F>(&mut self, op: F, padding0: bool)
Push a fallible unary operation that can manipulate the stack.
Sourcepub fn drop1<T, F>(&mut self, op: F, padding0: bool)where
F: Fn(T) + 'static,
T: 'static,
pub fn drop1<T, F>(&mut self, op: F, padding0: bool)where
F: Fn(T) + 'static,
T: 'static,
Push an operation that consumes and drops one value produced by op.
Sourcepub fn push_op2<T, U, R, F>(&mut self, op: F, padding0: bool, padding1: bool)where
F: Fn(T, U) -> R + 'static,
T: 'static,
U: 'static,
R: 'static,
pub fn push_op2<T, U, R, F>(&mut self, op: F, padding0: bool, padding1: bool)where
F: Fn(T, U) -> R + 'static,
T: 'static,
U: 'static,
R: 'static,
Pushes a binary operation that takes two arguments of types T and U and returns a value of type R.
Sourcepub fn raw2<T, U, R, F>(&mut self, op: F, padding0: bool, padding1: bool)
pub fn raw2<T, U, R, F>(&mut self, op: F, padding0: bool, padding1: bool)
Push a fallible binary operation that can manipulate the stack.
Sourcepub fn push_op3<T, U, V, R, F>(
&mut self,
op: F,
padding0: bool,
padding1: bool,
padding2: bool,
)where
F: Fn(T, U, V) -> R + 'static,
T: 'static,
U: 'static,
V: 'static,
R: 'static,
pub fn push_op3<T, U, V, R, F>(
&mut self,
op: F,
padding0: bool,
padding1: bool,
padding2: bool,
)where
F: Fn(T, U, V) -> R + 'static,
T: 'static,
U: 'static,
V: 'static,
R: 'static,
Pushes a ternary operation that takes three arguments of types T, U, and V and returns a value of type R.
Sourcepub fn raw3<T, U, V, R, F>(
&mut self,
op: F,
padding0: bool,
padding1: bool,
padding2: bool,
)
pub fn raw3<T, U, V, R, F>( &mut self, op: F, padding0: bool, padding1: bool, padding2: bool, )
Push a fallible ternary operation that can manipulate the stack.
Sourcepub unsafe fn call0<T>(&self) -> Result<T, Error>where
T: 'static,
pub unsafe fn call0<T>(&self) -> Result<T, Error>where
T: 'static,
Executes all operations in the segment and returns the final result.
§Errors
Halts execution and returns an error if any operation returns an error.
§Safety
This function is unsafe if the result type does not match the type returned by the operations in the segment or if the operations expect any initial values on the stack.
Sourcepub unsafe fn call1<A, T>(&self, arg: A) -> Result<T, Error>where
A: 'static,
T: 'static,
pub unsafe fn call1<A, T>(&self, arg: A) -> Result<T, Error>where
A: 'static,
T: 'static,
Executes all operations in the segment with one argument of type A and returns the final result.
§Errors
Halts execution and returns an error if any operation returns an error.
§Safety
This function is unsafe if the argument and result types do not match the types expected or returned by the operations in the segment.
Sourcepub unsafe fn call2<A, B, T>(&self, arg: (A, B)) -> Result<T, Error>where
A: 'static,
B: 'static,
T: 'static,
pub unsafe fn call2<A, B, T>(&self, arg: (A, B)) -> Result<T, Error>where
A: 'static,
B: 'static,
T: 'static,
Executes all operations in the segment with two arguments of types A and B and returns the final result.
§Errors
Halts execution and returns an error if any operation returns an error.
§Safety
This function is unsafe if the arguments and result types do not match the types expected or returned by the operations in the segment.