Struct brane_exe::pc::ProgramCounter
source · pub struct ProgramCounter {
pub func_id: FunctionId,
pub edge_idx: usize,
}
Expand description
Used to keep track of the current executing edge in a workflow.
Fields§
§func_id: FunctionId
The function ID of the function currently being executed.
edge_idx: usize
The edge that we’re executing in that function.
Implementations§
source§impl ProgramCounter
impl ProgramCounter
sourcepub fn new(
func_id: impl Into<FunctionId>,
edge_idx: impl AsPrimitive<usize>,
) -> Self
pub fn new( func_id: impl Into<FunctionId>, edge_idx: impl AsPrimitive<usize>, ) -> Self
Creates a new program counter from the given FunctionId
and the given index in that function.
§Arguments
func_id
: AFunctionId
-like to use as current function.edge_idx
: Ausize
-like to use as edge index within the givenfunc_id
.
§Returns
A new ProgramCounter instance.
sourcepub const fn start() -> Self
pub const fn start() -> Self
Creates a new program counter that points to the start of the <main>
-function.
§Returns
A new ProgramCounter instance.
sourcepub fn start_of(func_id: impl Into<FunctionId>) -> Self
pub fn start_of(func_id: impl Into<FunctionId>) -> Self
Creates a new program counter that points to the start of the given function.
§Arguments
func_id
: AFunctionId
-like to use as current function.
§Returns
A new ProgramCounter instance.
sourcepub fn jump(&self, next: impl AsPrimitive<usize>) -> Self
pub fn jump(&self, next: impl AsPrimitive<usize>) -> Self
Returns a ProgramCounter that points to the given edge within the same function.
This function returns a new instance. To update an existing one, use ProgramCounter::jump_mut()
.
§Arguments
next
: The edge index of the new edge within this function.
§Returns
A new ProgramCounter that points to the same function as self and the given next
.
sourcepub fn jump_mut(&mut self, next: impl AsPrimitive<usize>) -> &mut Self
pub fn jump_mut(&mut self, next: impl AsPrimitive<usize>) -> &mut Self
Updates this program counter with a new edge index.
This function mutates self
. To instead receive a new instance, use ProgramCounter::jump
§Arguments
next
: The edge index of the new edge within this function.
§Returns
Self for chaining.
sourcepub fn call(func: impl Into<FunctionId>) -> Self
pub fn call(func: impl Into<FunctionId>) -> Self
Returns a ProgramCounter that points to the start of another function.
This function returns a new instance. To update an existing one, use ProgramCounter::call_mut
.
§Arguments
func
: The identifier of the function to point to.
§Returns
A new ProgramCounter that points to the given func
and the first edge within (i.e., edge 0
).
sourcepub fn call_mut(&mut self, func: impl Into<FunctionId>) -> &mut Self
pub fn call_mut(&mut self, func: impl Into<FunctionId>) -> &mut Self
Updates this program counter such that it points to the start of the given function.
This function mutates self
. To instead receive a new instance, use ProgramCounter::call
.
§Arguments
func
: The identifier of the function to point to.
§Returns
Self for chaining.
sourcepub fn resolved(&self, symtable: &SymTable) -> ResolvedProgramCounter
pub fn resolved(&self, symtable: &SymTable) -> ResolvedProgramCounter
Returns a formatter that shows the resolved name of the function.
§Arguments
symtable
: A workflowSymTable
that is used to resolve the function identifiers to names.
§Returns
A ResolvedProgramCounter
that does the actual formatting as it implements Display
.
sourcepub fn is_main(&self) -> bool
pub fn is_main(&self) -> bool
Returns whether this ProgramCounter points to somewhere in the <main>
function.
§Returns
True if self.func_id.is_main()
is true, or else false.
Trait Implementations§
source§impl Add<usize> for ProgramCounter
impl Add<usize> for ProgramCounter
source§fn add(self, rhs: usize) -> Self::Output
fn add(self, rhs: usize) -> Self::Output
Adds a number of edges to this ProgramCounter.
§Arguments
rhs
: The number of edges to move forward.
§Returns
A new ProgramCounter
that points to the same function and the same edge index, except the latter is added to rhs
.
source§type Output = ProgramCounter
type Output = ProgramCounter
+
operator.source§impl AddAssign<usize> for ProgramCounter
impl AddAssign<usize> for ProgramCounter
source§fn add_assign(&mut self, rhs: usize)
fn add_assign(&mut self, rhs: usize)
Adds a number of edges to this ProgramCounter, but mutably instead of returning a new object.
§Arguments
rhs
: The number of edges to move forward.
source§impl Clone for ProgramCounter
impl Clone for ProgramCounter
source§fn clone(&self) -> ProgramCounter
fn clone(&self) -> ProgramCounter
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ProgramCounter
impl Debug for ProgramCounter
source§impl Default for ProgramCounter
impl Default for ProgramCounter
source§impl<'de> Deserialize<'de> for ProgramCounter
impl<'de> Deserialize<'de> for ProgramCounter
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
source§impl Display for ProgramCounter
impl Display for ProgramCounter
source§impl From<&ProgramCounter> for ProgramCounter
impl From<&ProgramCounter> for ProgramCounter
source§impl From<&mut ProgramCounter> for ProgramCounter
impl From<&mut ProgramCounter> for ProgramCounter
source§impl FromStr for ProgramCounter
impl FromStr for ProgramCounter
source§impl Hash for ProgramCounter
impl Hash for ProgramCounter
source§impl PartialEq for ProgramCounter
impl PartialEq for ProgramCounter
source§impl PartialOrd for ProgramCounter
impl PartialOrd for ProgramCounter
source§impl Serialize for ProgramCounter
impl Serialize for ProgramCounter
impl Copy for ProgramCounter
impl Eq for ProgramCounter
impl StructuralPartialEq for ProgramCounter
Auto Trait Implementations§
impl Freeze for ProgramCounter
impl RefUnwindSafe for ProgramCounter
impl Send for ProgramCounter
impl Sync for ProgramCounter
impl Unpin for ProgramCounter
impl UnwindSafe for ProgramCounter
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request