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:
- Create the struct
- Add capabilities
- 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]
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]
self
) -> Result<(Pin<Box<dyn Stream<Item = Result<ServerMessage>>>>, Pin<Box<dyn Sink<ClientMessage, Error = Error>>>, Ipv4Addr)>
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]
self,
addr: &Ipv4Addr
) -> Result<(Pin<Box<dyn Stream<Item = Result<ServerMessage>>>>, Pin<Box<dyn Sink<ClientMessage, Error = Error>>>)>
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
Auto Trait Implementations
impl RefUnwindSafe for SlimProto
impl RefUnwindSafe for SlimProto
impl UnwindSafe for SlimProto
impl UnwindSafe for SlimProto