Struct slimproto::proto::SlimProto[][src]

pub struct SlimProto { /* fields omitted */ }

The Slim Protocol struct is used to provide Stream and Sink objects for communicating with the server.

Normal procedure is to:

  1. Create the struct
  2. Add capabilities
  3. Connect to the server

e.g.

let mut proto = SlimProto::new();
proto
   .add_capability(Capability::Modelname("Example".to_owned()))
   .add_capability(Capability::Model("Example".to_owned()));
(mut proto_stream, mut proto_sink, server_address) = proto.connect().await.unwrap()

Implementations

impl SlimProto[src]

pub fn new() -> Self[src]

pub fn add_capability<'a>(&'a mut self, newcap: Capability) -> &'a mut Self[src]

Add a new capability to be sent ot the server. Note that capabilities are sent to the server in the order that they are added to the list. They are sent during the connect operation.

pub async fn connect(
    self
) -> Result<(Pin<Box<dyn Stream<Item = Result<ServerMessage>>>>, Pin<Box<dyn Sink<ClientMessage, Error = Error>>>, Ipv4Addr)>
[src]

Use autodiscover to find the server, connect to it and send the list of capabilities. Returns a Stream object that streams ServerMessage, a Sink object that accepts ClientMessage and the IPv4 address of the server.

pub async fn connect_to(
    self,
    addr: &Ipv4Addr
) -> Result<(Pin<Box<dyn Stream<Item = Result<ServerMessage>>>>, Pin<Box<dyn Sink<ClientMessage, Error = Error>>>)>
[src]

Connect to the server at the given address and send the list of capabilities. Returns a Stream object that streams ServerMessage and a Sink object that accepts ClientMessage.

Trait Implementations

impl Default for SlimProto[src]

Auto Trait Implementations

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.