Struct brane_ast::edgebuffer::EdgeBuffer

source ·
pub struct EdgeBuffer { /* private fields */ }
Expand description

Defines an EdgeBuffer, which is a muteable buffer to which we can compile edges.

Every buffer may be thought of as a single ‘stream’ of operations. If it branches for whatever reason, typically, multiple EdgeBuffers are involved the define each of the streams.

Because an EdgeBuffer is a single stream, it is implemented as a LinkedList of edges. Any branch is represented as links to other buffers.

Implementations§

source§

impl EdgeBuffer

source

pub fn new() -> EdgeBuffer

Constructor for the EdgeBuffer that initializes it to empty.

§Returns

An EdgeBufferPtr that refers to the newly instantiated object.

source

pub fn write(&mut self, edge: Edge)

Adds a new edge to the end of this EdgeBuffer.

Note that the function itself is agnostic to the specific kind of edge. The only requirement is that, when using EdgeBuffer::write(), the last edge in the buffer can linearly connect to this one. Be aware of this when writing non-Linear edges using this function.

§Arguments
  • edge: The Edge to append.
§Returns

Nothing, but does add it internally.

source

pub fn insert_at_end(&mut self, edge: Edge)

Adds a new edge to the end of this EdgeBuffer, although it is added before any stop/return/jump whatever.

Note that the function itself is agnostic to the specific kind of edge. The only requirement is that, when using EdgeBuffer::write(), the last non-returning edge in the buffer can linearly connect to this one. Be aware of this when writing non-Linear edges using this function.

§Arguments
  • edge: The Edge to append.
§Returns

Nothing, but does add it internally.

source

pub fn write_jump(&mut self, target: EdgeBufferNodePtr)

Adds a new (linear) edge to the end of this EdgeBuffer, but one that loops back to an earlier point in the buffer.

Note that the function itself is agnostic to the specific kind of edge. The only requirement is that, when using EdgeBuffer::write(), the last edge in the buffer can linearly connect to this one. Be aware of this when writing non-Linear edges using this function.

§Arguments
  • edge: The Edge to append.
  • target: The EdgeNode to wrap back to.
§Returns

Nothing, but does add it internally.

source

pub fn write_branch( &mut self, true_branch: Option<EdgeBuffer>, false_branch: Option<EdgeBuffer>, )

Adds a new branch to the end of this EdgeBuffer.

It will automatically be appended by an empty linear node that marks the ‘joining’ node of the Branch, unless there is a true and a false branch and both are returning (i.e., feature a return-branch in all paths).

Note that the function requires that the top edge on the buffer is linearly connectible. However, as a tradeoff, it also makes sure that it always is (as long as it doesn’t return).

§Arguments
  • true_branch: The Edges to take when the branch is taken (if any).
  • false_branch: The Edges to take when the branch is not taken (if any).
§Returns

Nothing, but does append the buffer with a new branch structure.

source

pub fn write_parallel( &mut self, branches: Vec<EdgeBuffer>, merge: MergeStrategy, )

Adds a new parallel to the end of this EdgeBuffer.

It will automatically be appended by a join.

Note that the function requires that the top edge on the buffer is linearly connectible. However, as a tradeoff, it also makes sure that it always is after this call.

§Arguments
  • branches: The Edges that represent each of the branches to run in parallel.
  • merge: The MergeStrategy that the generated join-edge needs to implement.
§Returns

Nothing, but does append the buffer with a new parallel structure.

source

pub fn write_loop(&mut self, condition: EdgeBuffer, consequence: EdgeBuffer)

Adds a new loop to the end of this EdgeBuffer.

It will automatically be appended by a ‘next edge to take’.

Note that the function requires that the top edge on the buffer is linearly connectible. However, as a tradeoff, it also makes sure that it always is after this call.

§Arguments
  • condition: The Edges that represent the condition computation.
  • consequence: The body of Edges that are actually repeated.
§Returns

Nothing, but does append the buffer with a new loop structure.

source

pub fn write_end(&mut self)

Adds a new end connection to the end of this EdgeBuffer.

Note that the function requires that the top edge on the buffer is linearly connectible. Because an end doesn’t connect, that means no EdgeBuffer::write*() can be used again.

§Arguments
  • end_edge: The edge that forms the actual end node. May be anything that linearly connects.
§Returns

Nothing, but does append the buffer with a new end structure.

source

pub fn write_stop(&mut self, stop_edge: Edge)

Adds a new stop to the end of this EdgeBuffer.

Note that the function requires that the top edge on the buffer is linearly connectible. Because an end doesn’t connect, that means no EdgeBuffer::write*() can be used again.

§Arguments
  • stop_edge: The edge that forms the actual end node. May only be ’Edge::ReturnorEdge::Stop`.
§Returns

Nothing, but does append the buffer with a new end structure.

source

pub fn append(&mut self, other: EdgeBuffer)

Appends the given EdgeBuffer to this one.

§Arguments
  • other: The EdgeBuffer to consume and append.
§Returns

Nothing, but does append the buffer with the new struct in the other buffer.

source

pub fn merge_linear(&mut self)

Merges all of the consecutive linear edges in this buffer to one edge.

§Returns

Nothing, but does merge some edges if they are consecutive and linear.

source

pub fn fully_returns(&self) -> bool

Helper function that traverses the EdgeBuffer to see if it fully returns.

§Returns

Whether or not this buffer fully returns (true) or not (false).

source

pub fn start(&self) -> &Option<EdgeBufferNodePtr>

Returns the start node of the EdgeBuffer, if any. This may be used for iteration.

Trait Implementations§

source§

impl Clone for EdgeBuffer

source§

fn clone(&self) -> EdgeBuffer

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 EdgeBuffer

source§

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

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

impl Default for EdgeBuffer

source§

fn default() -> Self

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

impl From<&EdgeBufferNodePtr> for EdgeBuffer

source§

fn from(value: &EdgeBufferNodePtr) -> Self

Converts to this type from the input type.
source§

impl From<EdgeBufferNodePtr> for EdgeBuffer

source§

fn from(value: EdgeBufferNodePtr) -> Self

Converts to this type from the input type.

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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FromRef<T> for T
where T: Clone,

source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
source§

impl<T> ToOwned for T
where T: Clone,

source§

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

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T