[][src]Struct buttplug::client::internal::ButtplugClientInternalLoop

pub struct ButtplugClientInternalLoop { /* fields omitted */ }

The internal event loop for the [ButtplugClient].

Created whenever a new [ButtplugClient] is created, the internal loop handles connection and communication with the server, and creation of events received from the server. As [ButtplugClient] is clonable, multiple ButtplugClient instances can exist that all communicate with the same ButtplugClientInternalLoop.

Also, if multiple [ButtplugClient] instances are created via new(), multiple ButtplugClientInternalLoops can run in parallel. This allows applications to possibly create connections to multiple [ButtplugServer] instances.

Methods

impl ButtplugClientInternalLoop[src]

pub fn new(
    event_sender: Sender<ButtplugMessageUnion>,
    client_receiver: Receiver<ButtplugInternalClientMessage>
) -> Self
[src]

Returns a new ButtplugClientInternalLoop instance.

This should really only ever be constructed by a [ButtplugClient], and there should only be one per new [ButtplugClient].

Parameters

  • event_sender: Used when sending server updates to clients.
  • client_receiver: Used when receiving commands from clients to send to server.

pub async fn event_loop<'_>(&'_ mut self)[src]

The internal event loop for [ButtplugClient] connection and communication

The event_loop does a few different things during its lifetime.

  • The first thing it will do is wait for a Connect message from a client. This message contains a ButtplugClientConnector that will be used to connect and communicate with a [ButtplugServer].

  • After a connection is established, it will listen for events from the connector, or messages from the client, until either server/client disconnects.

  • Finally, on disconnect, it will tear down, and cannot be used again. All clients and devices associated with the loop will be invalidated, and a new [ButtplugClient] (and corresponding ButtplugClientInternalLoop) must be created.

Trait Implementations

impl Send for ButtplugClientInternalLoop[src]

Make ButtplugClientInternalLoop sendable across threads.

Since this loop will usually be run in a future somewhere, and we don't know where, this needs to be send.

impl Sync for ButtplugClientInternalLoop[src]

Auto Trait Implementations

Blanket Implementations

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

impl<T> From<T> for 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<T> Borrow<T> for T where
    T: ?Sized
[src]

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

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