Struct varlink::VarlinkService

source ·
pub struct VarlinkService { /* private fields */ }
Expand description

VarlinkService handles all the I/O and dispatches method calls to the registered interfaces.

Implementations§

Create a new VarlinkService.

See the Service section of the varlink wiki about the vendor, product, version and url.

The interfaces vector is an array of varlink Interfaces this service provides.

Examples
let service = varlink::VarlinkService::new(
    "org.varlink",
    "test service",
    "0.1",
    "http://varlink.org",
    vec![
        Box::new(interface_foo),
        Box::new(interface_bar),
        Box::new(interface_baz),
    ],
);

Trait Implementations§

handle() consumes every null terminated message from reader and writes the reply to writer.

This method can be used to implement your own server. Pass it one or more null terminated received messages in a BufReader and reply to the sender with the filled writer buffer.

Returns Ok(true), if the connection is upgraded. For upgraded connections messages are in legacy format and

Examples
use varlink::{ConnectionHandler, VarlinkService};

let service = VarlinkService::new(
    "org.varlink",
    "test service",
    "0.1",
    "http://varlink.org",
    vec![], // more interfaces ...
);
let mut in_buf = io::BufReader::new("received null terminated message(s) go here \000".as_bytes());
let mut out: Vec<u8> = Vec::new();
assert!(service.handle(&mut in_buf, &mut out, None).is_ok());

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.