Skip to main content

RawSegment

Struct RawSegment 

Source
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

Source

pub fn new() -> RawSegment

Creates a new empty segment.

Source

pub fn raw0_<F>(&mut self, op: F)
where F: Fn(&mut RawStack) -> Result<(), Error> + 'static,

Pushes a closure that manipulates the stack directly and returns ().

Source

pub fn raw0<R, F>(&mut self, op: F)
where F: Fn(&mut RawStack) -> Result<R, Error> + 'static, R: 'static,

Push a closure that manipulates the stack and returns a value R.

Source

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.

Source

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.

Source

pub fn raw1<T, R, F>(&mut self, op: F, padding0: bool)
where F: Fn(&mut RawStack, T) -> Result<R, Error> + 'static, T: 'static, R: 'static,

Push a fallible unary operation that can manipulate the stack.

Source

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.

Source

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.

Source

pub fn raw2<T, U, R, F>(&mut self, op: F, padding0: bool, padding1: bool)
where F: Fn(&mut RawStack, T, U) -> Result<R, Error> + 'static, T: 'static, U: 'static, R: 'static,

Push a fallible binary operation that can manipulate the stack.

Source

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.

Source

pub fn raw3<T, U, V, R, F>( &mut self, op: F, padding0: bool, padding1: bool, padding2: bool, )
where F: Fn(&mut RawStack, T, U, V) -> Result<R, Error> + 'static, T: 'static, U: 'static, V: 'static, R: 'static,

Push a fallible ternary operation that can manipulate the stack.

Source

pub unsafe fn call0_stack(&self, stack: &mut RawStack) -> Result<(), Error>

Executes all operations in the segment on the supplied stack.

§Errors

Halts execution and returns an error if any operation returns an error.

§Safety

Precondition: The stack must be in the correct state (base alignment, index, and values) for the operations in the segment.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Default for RawSegment

Source§

fn default() -> RawSegment

Returns the “default value” for a type. Read more
Source§

impl Drop for RawSegment

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.