[][src]Trait buttplug::connector::ButtplugConnector

pub trait ButtplugConnector<OutboundMessageType, InboundMessageType>: Send + Sync where
    OutboundMessageType: ButtplugMessage + 'static,
    InboundMessageType: ButtplugMessage + 'static, 
{ fn connect(
        &mut self
    ) -> BoxFuture<'static, Result<Receiver<Result<InboundMessageType, ButtplugServerError>>, ButtplugConnectorError>>;
fn disconnect(&self) -> ButtplugConnectorResultFuture;
fn send(&self, msg: OutboundMessageType) -> ButtplugConnectorResultFuture; }

Trait for client connectors.

Connectors are how Buttplug Clients and servers talk to each other. Whether embedded, meaning the client and server exist in the same process space, or remote, where the client and server are separated by some boundary, the connector trait makes it so that these components always look local.

The O type specifies the outbound message type. This will usually be a message enum. For instance, in a client connector, this would usually be [ButtplugClientOutMessage][crate::core::messages::ButtplugClientOutMessage].

The I type specifies the inbound message type. This will usually be a message enum. For instance, in a client connector, this would usually be [ButtplugClientInMessage][crate::core::messages::ButtplugClientInMessage].

Required methods

fn connect(
    &mut self
) -> BoxFuture<'static, Result<Receiver<Result<InboundMessageType, ButtplugServerError>>, ButtplugConnectorError>>

Connects the client to the server.

Tries to connect to another connector, returning an event stream of incoming messages (of type I) on successful connect.

Errors

Returns a [ButtplugClientConnectorError] if there is a problem with the connection process. It is assumed that all information needed to create the connection will be passed as part of the Trait implementors creation methods.

Async

As connection may involve blocking operations like establishing network connections, this trait method is marked async.

fn disconnect(&self) -> ButtplugConnectorResultFuture

Disconnects the client from the server.

Returns a [ButtplugClientConnectorError] if there is a problem with the disconnection process.

Async

As disconnection may involve blocking operations like network closing and cleanup, this trait method is marked async.

fn send(&self, msg: OutboundMessageType) -> ButtplugConnectorResultFuture

Sends a message of outbound message type O to the other connector.

Errors

If the connector is not currently connected, or an error happens during the send operation, this will return a ButtplugConnectorError

Loading content...

Implementors

impl ButtplugConnector<ButtplugSpecV2ClientMessage, ButtplugSpecV2ServerMessage> for ButtplugInProcessClientConnector[src]

impl<TransportType, SerializerType, OutboundMessageType, InboundMessageType> ButtplugConnector<OutboundMessageType, InboundMessageType> for ButtplugRemoteConnector<TransportType, SerializerType, OutboundMessageType, InboundMessageType> where
    TransportType: ButtplugConnectorTransport + 'static,
    SerializerType: ButtplugMessageSerializer<Inbound = InboundMessageType, Outbound = OutboundMessageType> + 'static,
    OutboundMessageType: ButtplugMessage + 'static,
    InboundMessageType: ButtplugMessage + 'static, 
[src]

Loading content...