pub struct Span { /* private fields */ }
Expand description

A code block used to describe a linear sequence of operations (i.e., no branching or loops).

When the VM executes a Span block, it breaks the sequence of operations into batches and groups according to the following rules:

  • A group may contain up to 9 operations or a single immediate value.
  • An operation carrying an immediate value cannot be in the 9th position in a group.
  • A batch may contain up to 8 groups.
  • There is no limit on the number of batches contained within a single span.

Thus, for example, executing 8 pushes in a row will result in two operation batches:

  • The first batch will contain 8 groups, with the first group containing 7 push opcodes, and the remaining 7 groups containing immediate values for each of the push operations.
  • The second batch will contain 2 groups, with the first group containing a single push opcode, and the second group containing the immediate value for the last push operation.

If a sequence of operations does not have any operations which carry immediate values, then up to 72 operations can fit into a single batch.

TODO: describe how Span hash is computed.

Implementations§

source§

impl Span

source

pub const DOMAIN: Felt = Felt::ZERO

The domain of the span block (used for control block hashing).

source

pub fn new(operations: Vec<Operation>) -> Self

Returns a new Span block instantiated with the specified operations.

Errors (TODO)

Returns an error if:

  • operations vector is empty.
  • operations vector contains any number of system operations.
source

pub fn with_decorators( operations: Vec<Operation>, decorators: DecoratorList ) -> Self

Returns a new Span block instantiated with the specified operations and decorators.

Errors (TODO)

Returns an error if:

  • operations vector is empty.
  • operations vector contains any number of system operations.
source

pub fn hash(&self) -> Digest

Returns a hash of this code block.

source

pub fn op_batches(&self) -> &[OpBatch]

Returns list of operation batches contained in this span block.

source

pub fn replicate(&self, num_copies: usize) -> Self

Returns a new Span block instantiated with operations from this block repeated the specified number of times.

source

pub fn decorators(&self) -> &DecoratorList

Returns a list of decorators in this span block

source

pub fn decorator_iter(&self) -> DecoratorIterator<'_>

Returns a DecoratorIterator which allows us to iterate through the decorator list of this span block while executing operation batches of this span block

Trait Implementations§

source§

impl Clone for Span

source§

fn clone(&self) -> Span

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Span

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for Span

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Span

§

impl Send for Span

§

impl Sync for Span

§

impl Unpin for Span

§

impl UnwindSafe for Span

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.