Struct Context

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

A representation of shared state.

This is an umbrella type which, currently, includes a collection of Atoms, two symbol tables (one for structure names, and another for node names), node capacities, harc weights, and PartialContent of any c-e structure created in this Context.

For usage, see ContextHandle type, Contextual trait and InContext struct.

Implementations§

Source§

impl Context

Source

pub fn new_toplevel<S>(name: S) -> Arc<Mutex<Context>>
where S: AsRef<str>,

Creates a new toplevel Context instance and returns the corresponding ContextHandle.

Calling this method is the only public way of creating toplevel Context instances.

Source

pub fn reset(&mut self)

Clears content map, capacities, weights and runtime attributes, but doesn’t destroy shared resources.

This method preserves the collection of [Atom]s, the two symbol tables, and the Context’s own given name and group ID.

Source

pub fn new_derived<S>( name: S, parent: &Arc<Mutex<Context>>, ) -> Arc<Mutex<Context>>
where S: AsRef<str>,

Creates a new derived Context instance and returns a corresponding ContextHandle.

Calling this method is the only public way of creating derived Context instances.

Source

pub fn is_toplevel(&self) -> bool

Source

pub fn is_derived(&self) -> bool

Source

pub fn get_name(&self) -> &str

Source

pub fn share_node_name<S>(&mut self, node_name: S) -> NodeID
where S: AsRef<str>,

Source

pub fn get_node_name(&self, node_id: NodeID) -> Option<&str>

Source

pub fn get_node_id<S>(&self, node_name: S) -> Option<NodeID>
where S: AsRef<str>,

Source

pub fn is_port(&self, atom_id: NonZero<usize>) -> bool

Source

pub fn is_harc(&self, atom_id: NonZero<usize>) -> bool

Source

pub fn is_fork(&self, atom_id: NonZero<usize>) -> bool

Source

pub fn is_join(&self, atom_id: NonZero<usize>) -> bool

Source

pub fn share_port(&mut self, port: &mut Port) -> PortID

Source

pub fn share_fork(&mut self, fork: &mut Harc) -> ForkID

Source

pub fn share_join(&mut self, join: &mut Harc) -> JoinID

Source

pub fn get_port(&self, port_id: PortID) -> Option<&Port>

Source

pub fn get_harc(&self, atom_id: NonZero<usize>) -> Option<&Harc>

Source

pub fn get_fork(&self, fork_id: ForkID) -> Option<&Harc>

Source

pub fn get_join(&self, join_id: JoinID) -> Option<&Harc>

Source

pub fn get_antiport_id(&self, port_id: PortID) -> Option<PortID>

Source

pub fn add_content<S>( &mut self, name: S, content: PartialContent, ) -> Option<PartialContent>
where S: AsRef<str>,

Source

pub fn get_content<S>(&self, name: S) -> Option<&PartialContent>
where S: AsRef<str>,

Source

pub fn has_content<S>(&self, name: S) -> bool
where S: AsRef<str>,

Source

pub fn set_capacity_by_name<S>( &mut self, node_name: S, cap: Multiplicity, ) -> Option<Multiplicity>
where S: AsRef<str>,

Source

pub fn get_capacity(&self, node_id: NodeID) -> Multiplicity

Source

pub fn set_weight_by_name<S, I>( &mut self, face: Face, host_name: S, suit_names: I, weight: Multiplicity, ) -> Option<Multiplicity>
where S: AsRef<str>, I: IntoIterator, <I as IntoIterator>::Item: AsRef<str>,

Source

pub fn set_inhibitor_by_name<S, I>( &mut self, face: Face, host_name: S, suit_names: I, ) -> Option<Multiplicity>
where S: AsRef<str>, I: IntoIterator, <I as IntoIterator>::Item: AsRef<str>,

Source

pub fn set_holder_by_name<S, I>( &mut self, face: Face, host_name: S, suit_names: I, ) -> Option<Multiplicity>
where S: AsRef<str>, I: IntoIterator, <I as IntoIterator>::Item: AsRef<str>,

Source

pub fn get_weight(&self, atom_id: NonZero<usize>) -> Multiplicity

Source

pub fn set_encoding(&mut self, encoding: Encoding)

Source

pub fn get_encoding(&self) -> Option<Encoding>

Source

pub fn set_semantics(&mut self, semantics: Semantics)

Source

pub fn get_semantics(&self) -> Option<Semantics>

Source

pub fn set_max_steps(&mut self, max_steps: usize)

Source

pub fn get_max_steps(&self) -> Option<usize>

Source

pub fn set_title<S>(&mut self, title: S)
where S: AsRef<str>,

Source

pub fn get_title(&self) -> Option<&str>

Source

pub fn set_label<S>(&mut self, node_id: NodeID, label: S)
where S: AsRef<str>,

Source

pub fn get_label(&self, node_id: NodeID) -> Option<&str>

Trait Implementations§

Source§

impl Debug for Context

Source§

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

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

impl PartialEq for Context

Source§

fn eq(&self, other: &Context) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Context

Source§

fn partial_cmp(&self, other: &Context) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Eq for Context

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<Reference, Outer, OuterFieldType, Inner> HasPart<Nested<Outer, Inner>> for Reference
where Reference: HasPart<Outer> + ?Sized, Outer: Part<PartType = Field<OuterFieldType>>, Inner: Part, OuterFieldType: HasPart<Inner, RawTarget = OuterFieldType> + PartialRefTarget + ?Sized,

Source§

unsafe fn part_ptr( ptr: *const <Reference as PartialRefTarget>::RawTarget, ) -> <<Inner as Part>::PartType as PartType>::Ptr

Given a constant pointer to a target, produce a constant pointer to a part of it.
Source§

unsafe fn part_ptr_mut( ptr: *mut <Reference as PartialRefTarget>::RawTarget, ) -> <<Inner as Part>::PartType as PartType>::PtrMut

Given a mutable pointer to a target, produce a mutable pointer to a part of it.
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V