Struct varlink::VarlinkService [−][src]
VarlinkService handles all the I/O and dispatches method calls to the registered interfaces.
Implementations
impl VarlinkService
[src]
pub fn new<S: Into<Cow<'static, str>>>(
vendor: S,
product: S,
version: S,
url: S,
interfaces: Vec<Box<dyn Interface + Send + Sync>>
) -> Self
[src]
vendor: S,
product: S,
version: S,
url: S,
interfaces: Vec<Box<dyn Interface + Send + Sync>>
) -> Self
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
impl ConnectionHandler for VarlinkService
[src]
fn handle(
&self,
bufreader: &mut dyn BufRead,
writer: &mut dyn Write,
upgraded_last_interface: Option<String>
) -> Result<(Vec<u8>, Option<String>)>
[src]
&self,
bufreader: &mut dyn BufRead,
writer: &mut dyn Write,
upgraded_last_interface: Option<String>
) -> Result<(Vec<u8>, Option<String>)>
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());
impl Interface for VarlinkService
[src]
Auto Trait Implementations
impl !RefUnwindSafe for VarlinkService
impl Send for VarlinkService
impl Sync for VarlinkService
impl Unpin for VarlinkService
impl !UnwindSafe for VarlinkService
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,