Struct Port

Source
pub struct Port<T: Sync> { /* private fields */ }
Expand description

Represents a port, which carries values of type T. Ports reify the data inputs and outputs of a reactor.

They may be bound to another port, in which case the upstream port forwards all values to the output port (logically instantaneously). A port may have only one upstream binding.

Output ports may also be explicitly set within a reaction, in which case they may not have an upstream port binding.

Those structural constraints are trusted to have been verified by the code generator. If necessary we may be able to add conditional compilation flags that enable runtime checks.

Trait Implementations§

Source§

impl<T: Sync> ReactionTrigger<T> for Port<T>

Source§

fn is_present(&self, _now: &EventTag, _start: &Instant) -> bool

Returns whether the trigger is present, given that the current logical time is the parameter.
Source§

fn get_value(&self, _now: &EventTag, _start: &Instant) -> Option<T>
where T: Copy,

Copies the value out, if it is present. Whether a value is present is not in general the same thing as whether this trigger Self::is_present. See crate::ReactionCtx::get.
Source§

fn use_value_ref<O>( &self, _now: &EventTag, _start: &Instant, action: impl FnOnce(Option<&T>) -> O, ) -> O

Execute an action using the current value of this trigger. The closure is called even if the value is absent (with a None argument).

Auto Trait Implementations§

§

impl<T> Freeze for Port<T>

§

impl<T> !RefUnwindSafe for Port<T>

§

impl<T> !Send for Port<T>

§

impl<T> !Sync for Port<T>

§

impl<T> Unpin for Port<T>

§

impl<T> !UnwindSafe for Port<T>

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.