Struct Client

Source
pub struct Client { /* private fields */ }
Expand description

The Client end of a connection to the Coordinator

See library documentation for an example of constructing a Client.

Implementations§

Source§

impl Client

Source

pub async fn new( config: ClientConfig, ) -> Result<(Self, IncomingStreams), ClientError>

Construct a Client and connect to the Coordinator

Source

pub fn new_proxied_stream(&mut self, to: String) -> ConnectingStream

Open a new stream to another client, proxied through the Coordinator

Source

pub fn new_direct_stream(&mut self, to: String) -> ConnectingStream

Open a new stream to another client via a direct channel.

It is only possible to open another stream to a client for which there is an open channel, either because that client connected to this one or because this client called Client::new_channel.

Source

pub fn new_stream_with_id(&self, to: String, sid: StreamId) -> ConnectingStream

Open a new proxied stream to another client with an explicit stream-id. This can be useful for coordination in applications where peers share multiple data streams (e.g., clients might agree that sid 1 is for values of type T1, sid 2 is for values of type T2, etc.).

The sid argument must be different for every call to this function for a given Client object. If mixing calls to this function with calls to Client::new_proxied_stream or Client::new_direct_stream, avoid using sid >= 1<<63, since these values are used automatically by those functions.

Source

pub fn new_channel(&mut self, to: String) -> ConnectingChannel

Open a new channel directly to another client

Note that a client that is not listening for new channels can nevertheless open a new channel to one that is listening.

Source

pub fn close_channel(&self, peer: String) -> ClosingChannel

Close an open channel

Currently, attempting to re-open a channel after closing causes what appears to be a transport error. XXX(#1)

Source

pub fn new_broadcast(&mut self, chan: String) -> ConnectingStream

Open or connect to a broadcast stream

A broadcast stream is a many-to-many stream proxied through the Coordinator. Any Client who knows the stream’s name can send to and receive from it.

Broadcast streams may suffer from the slow receiver problem: senders cannot make progress until the slowest receiver drains its incoming buffer. The NonblockingInStream adapter may help to address this issue.

Source

pub fn new_stream(&mut self, to: String) -> ConnectingStream

Open a new stream to another client

This function first attempts to open a direct stream to the client and then, if that fails, falls back to a proxied stream through the Coordinator.

Source

pub fn get_broadcast_count(&mut self, chan: String) -> BroadcastCounting

Count the current members of a broadcast channel

Request from Coordinator the current count of senders and receivers on a given broadcast channel. The result is a future that, when forced, returns either an error or the tuple (#senders, #receivers).

Auto Trait Implementations§

§

impl Freeze for Client

§

impl !RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl !UnwindSafe for Client

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

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more