Struct Output

Source
pub struct Output<T: Clone + Send + 'static> { /* private fields */ }
Expand description

An output port.

Output ports can be connected to input ports, i.e. to asynchronous model methods that return no value. They broadcast events to all connected input ports.

Implementations§

Source§

impl<T: Clone + Send + 'static> Output<T>

Source

pub fn new() -> Self

Creates a new, disconnected Output port.

Source

pub fn connect<M, F, S>( &mut self, input: F, address: impl Into<Address<M>>, ) -> LineId
where M: Model, F: for<'a> InputFn<'a, M, T, S> + Copy, S: Send + 'static,

Adds a connection to an input port of the model specified by the address.

The input port must be an asynchronous method of a model of type M taking as argument a value of type T plus, optionally, a scheduler reference.

Source

pub fn connect_stream(&mut self) -> (EventStream<T>, LineId)

Adds a connection to an event stream iterator.

Source

pub fn connect_slot(&mut self) -> (EventSlot<T>, LineId)

Adds a connection to an event slot.

Source

pub fn disconnect(&mut self, line_id: LineId) -> Result<(), LineError>

Removes the connection specified by the LineId parameter.

It is a logic error to specify a line identifier from another Output or Requestor instance and may result in the disconnection of an arbitrary endpoint.

Source

pub fn disconnect_all(&mut self)

Removes all connections.

Source

pub async fn send(&mut self, arg: T)

Broadcasts an event to all connected input ports.

Trait Implementations§

Source§

impl<T: Clone + Send + 'static> Debug for Output<T>

Source§

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

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

impl<T: Clone + Send + 'static> Default for Output<T>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<T> Freeze for Output<T>

§

impl<T> !RefUnwindSafe for Output<T>

§

impl<T> Send for Output<T>

§

impl<T> !Sync for Output<T>

§

impl<T> Unpin for Output<T>

§

impl<T> !UnwindSafe for Output<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.