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: CenterCenter used for getting message origins. Is currently public to allow the user to read the center Address.
Implementations§
Source§impl Interface
impl Interface
Sourcepub fn new(config: Config, center: Center) -> Result<Self, Error>
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.
Sourcepub fn subscribe(&self, addr: &Address) -> Topic
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.
Sourcepub fn send(&self, transaction: Transaction) -> Result<(), Error>
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.
Sourcepub fn try_recv(&self) -> Option<Transaction>
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.
Sourcepub fn recv(&self) -> Option<Transaction>
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.