Skip to main content

Program

Struct Program 

Source
pub struct Program { /* private fields */ }
Expand description

A linked, ready-to-execute program.

Created from StoryData via link(). Immutable after creation — mutable per-instance state lives in Story.

Implementations§

Source§

impl Program

Source

pub fn resolve_address(&self, id: DefinitionId) -> Option<(u32, usize)>

Resolve a definition ID to (container_idx, byte_offset).

Source

pub fn container_bytecode(&self, idx: u32) -> &[u8]

Get a container’s bytecode by index.

Source

pub fn container_count(&self) -> u32

Number of containers.

Source

pub fn source_checksum(&self) -> u32

CRC-32 checksum from the source .inkb, used for transcript validation.

Source

pub fn find_address(&self, path: &str) -> Option<(u32, usize)>

Resolve a qualified ink path to its (container_idx, byte_offset).

Supports knot names (intro), qualified stitches (knot.stitch), and, for programs compiled by brink-compiler, author labels (knot.label, knot.stitch.label). Programs without the compiler’s address_paths table (legacy .inkb or converter output) resolve knot/stitch scope paths only. Use this to spawn flows at named entry points:

if let Some((idx, _)) = program.find_address("intro_scene") {
    let (flow, ctx) = FlowInstance::new_at(program, idx);
}
Source

pub fn global_defaults(&self) -> Vec<Value>

Build the initial globals vector from slot defaults.

Source

pub fn global_index(&self, name: &str) -> Option<u32>

Find the global variable slot index for a variable name, if declared. Used by host-facing variable get/set (Story::variable/set_variable).

Source

pub fn global_name(&self, idx: u32) -> Option<&str>

Resolve a global slot index to its variable name.

Source

pub fn global_count(&self) -> u32

Number of global variable slots.

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, 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.