[][src]Struct dqcsim::plugin::connection::Connection

pub struct Connection { /* fields omitted */ }

Plugin to Simulator connection wrapper.

This provides a Plugin with the ability to communicate with both a Simulator instance and other upstream and downstream plugins.

Constructing a Connection instance should be the first thing a Plugin does. The Simulator server address string is passed as an argument to all Plugins started by a Simulator. The server address string can be used to construct a Connection instance.

After constructin of the Connection instance, the Plugin can respond to the initialization request from the Simulator.

Implementations

impl Connection[src]

pub fn new(simulator: impl Into<String>) -> Result<Connection>[src]

Construct a Connection wrapper instance.

The Connection wrapper attempts to connect to the Simulator using the address provided as argument. The required communication channels are generated and exchanged with the Simulator.

At this point the Connection wrapper can receive requests and send responses from and to the Simulator, however logging and upstream and downstream plugin connections are not yet available.

The first request the Simulator sends is always an initialization request, which should be handled with the init method.

pub fn connect_downstream(
    &mut self,
    downstream: impl Into<String>
) -> Result<()>
[src]

Connects to a downstream plugin.

pub fn serve_upstream(&mut self) -> Result<String>[src]

Creates a one-shot server for an upstream plugin to connect to, returning the address. Call accept_upstream() to finish connecting.

pub fn accept_upstream(&mut self) -> Result<()>[src]

Waits for an upstream plugin to connect to our one-shot server and establishes the connection. Call serve_upstream() first.

pub fn send(&self, message: OutgoingMessage) -> Result<()>[src]

Send an OutgoingMessage.

Send an OutgoingMessage using the corresponding sender. Returns an error when the channel is closed, does not exist or when sending failed.

pub fn next_request(&mut self) -> Result<Option<IncomingMessage>>[src]

Fetch next request from either the Simulator request channel or the upstream Plugin request channel.

Fails if either connection closed or if any connection is unexpectedly already closed. Returns Ok(None) if both request channels are closed. This method blocks until a new request is available.

pub fn next_downstream_request(&mut self) -> Result<Option<IncomingMessage>>[src]

Fetch next downstream request.

Fails if the downstream connection is closed. This method blocks until a new request is available.

Trait Implementations

impl Drop for Connection[src]

Auto Trait Implementations

impl !RefUnwindSafe for Connection

impl Send for Connection

impl !Sync for Connection

impl Unpin for Connection

impl UnwindSafe for Connection

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,