Crate ssb_client [] [src]

A client library for interfacing with ssb.

This example is not tested
sodiumoxide::init();
let addr = SocketAddr::new(Ipv6Addr::localhost().into(), DEFAULT_TCP_PORT);

current_thread::run(|_| {
    current_thread::spawn(TcpStream::connect(&addr)
    .and_then(|tcp| easy_ssb(tcp).unwrap().map_err(|err| panic!("{:?}", err)))
    .map_err(|err| panic!("{:?}", err))
    .map(|(mut client, receive, _)| {
        current_thread::spawn(receive.map_err(|err| panic!("{:?}", err)));

        let (send_request, response) = client.whoami();

        current_thread::spawn(send_request.map_err(|err| panic!("{:?}", err)));
        current_thread::spawn(response
                                  .map(|res| println!("{:?}", res))
                                  .map_err(|err| panic!("{:?}", err))
                                  .and_then(|_| {
                                                client.close().map_err(|err| panic!("{:?}", err))
                                            }));
    }))
});

Structs

Client

An ssb client. This struct is used to send rpcs to the server.

Close

A future for closing the connection to the server. If there are still active rpcs, it is not closed immediately. It will get closed once the last of them is done.

Closed

A future that indicates when the write-half of the channel to the server has been closed.

EasySsb

A future for setting up an encrypted connection via the given AsyncRead and AsyncWrite (using keys from the ssb keyfile) and then calling ssb on the connection.

Receive

A future that has to be polled in order to receive responses from the server.

SendRpc

A future for sending an rpc to the server. If this isn't polled, the rpc is never sent.

Whoami

Query information about the current user.

Enums

EasySsbError

Everything that can go wrong when creating a client via easy_ssb.

Functions

easy_ssb

Return a future for setting up an encrypted connection via the given transport (using keys from the ssb keyfile) and then calling ssb on the connection.

ssb

Take ownership of an AsyncRead and an AsyncWrite to create an ssb client.