Interface

Struct Interface 

Source
pub struct Interface {
    pub center: Center,
    /* private fields */
}
Expand description

Starting the switch will create both Interface and Switch objects. The Interface will be passed up and to the user / instance. From there the user can interact (receive messages) with the listener.

Fields§

§center: Center

Center used for getting message origins. Is currently public to allow the user to read the center Address.

Implementations§

Source§

impl Interface

Source

pub fn new(config: Config, center: Center) -> Result<Self, Error>

Currently there are no dedicated functions for creating and starting the components. Instead this function does both:

  • It creates all the internally shared components like the RecordBucket and the Table.

  • It creates all the thread objects required.

  • It starts all threads.

Should any of the steps fail the entire function fails, which means the system is unable to start.

Source

pub fn subscribe(&self, addr: &Address) -> Topic

Creates a new Topic, both locally, on the Switch thread and (possilby) remotely. The local topic returned contains a list of subscribers (that will get updated and refreshed on demand) as well as a Channel to the Switch. From there any updates are processed.

Source

pub fn send(&self, transaction: Transaction) -> Result<(), Error>

It is possible to ignore the entire PubSub architecture and just send messages to another user directly. For that the exact Address has to be known. From there a Transaction can be constructed and distributed through the system. This function is only recommended for specific, special reasons, otherwise the message function can be used.

Source

pub fn try_recv(&self) -> Option<Transaction>

Tries to read a message from the Interface Channel without blocking. It only returns a transaction if a Message event was received, any other type will be ignored.

Source

pub fn recv(&self) -> Option<Transaction>

Mostly the same as try_recv(), but it blocks until a Message event is available. Should it ever return None it is likely, that the Switch is no longer available.

Source

pub fn message(&self, target: Address, body: Vec<u8>) -> Result<(), Error>

Constructs a new Transaction from the provided target and body and completes the missing values. The created Transaction will be distributed automatically.

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<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> Same for T

Source§

type Output = T

Should always be Self
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