pub struct RpcConn { /* private fields */ }
Expand description

Convenience wrapper around the lowlevel connection

use rustbus::{connection::{Timeout, ll_conn::force_finish_on_error}, standard_messages, MessageBuilder, MessageType, RpcConn};
// Connect to the session bus. This also takes care of the mandatory hello messages
let mut rpc_con = RpcConn::session_conn(Timeout::Infinite).unwrap();
let mut call = MessageBuilder::new()
    .call("evaluateScript")
    .with_interface("org.kde.PlasmaShell")
    .on("/PlasmaShell")
    .at("org.kde.plasmashell")
    .build();

let id = rpc_con
    .send_message(&mut call)
    .expect("Wanna send message :(")
    .write_all()
    .map_err(force_finish_on_error)
    .expect("Wanna send message :(");

let message = rpc_con
    .wait_response(id, Timeout::Infinite)
    .expect("Get failed");

Implementations§

source§

impl RpcConn

source

pub fn new(conn: DuplexConn) -> Self

source

pub fn conn(&self) -> &DuplexConn

source

pub fn conn_mut(&mut self) -> &mut DuplexConn

source

pub fn alloc_serial(&mut self) -> u32

get the next new serial

source

pub fn session_conn(timeout: Timeout) -> Result<Self, Error>

source

pub fn system_conn(timeout: Timeout) -> Result<Self, Error>

source

pub fn connect_to_path(path: UnixAddr, timeout: Timeout) -> Result<Self, Error>

source

pub fn set_filter(&mut self, filter: MessageFilter)

source

pub fn try_get_response(&mut self, serial: u32) -> Option<MarshalledMessage>

Return a response if one is there but dont block

source

pub fn wait_response( &mut self, serial: u32, timeout: Timeout ) -> Result<MarshalledMessage, Error>

Return a response if one is there or block until it arrives

source

pub fn try_get_signal(&mut self) -> Option<MarshalledMessage>

Return a signal if one is there but dont block

source

pub fn wait_signal( &mut self, timeout: Timeout ) -> Result<MarshalledMessage, Error>

Return a sginal if one is there or block until it arrives

source

pub fn try_get_call(&mut self) -> Option<MarshalledMessage>

Return a call if one is there but dont block

source

pub fn wait_call( &mut self, timeout: Timeout ) -> Result<MarshalledMessage, Error>

Return a call if one is there or block until it arrives

source

pub fn send_message<'a>( &'a mut self, msg: &'a mut MarshalledMessage ) -> Result<SendMessageContext<'a>, Error>

Send a message to the bus

source

pub fn try_refill_once( &mut self, timeout: Timeout ) -> Result<Option<MessageType>, Error>

This processes ONE message. This might be an ignored message. The result will tell you which if any message type was received. The message will be placed into the appropriate queue in the RpcConn.

If a call is received that should be filtered out an error message is sent automatically

source

pub fn refill_once(&mut self, timeout: Timeout) -> Result<MessageType, Error>

This blocks until a new message (that should not be ignored) arrives. The message gets placed into the correct list. The Result will tell you which kind of message has been received.

If calls are received that should be filtered out an error message is sent automatically

source

pub fn refill_all(&mut self) -> Result<Vec<MarshalledMessage>, Error>

This will drain all outstanding IO on the socket, this will never block. If there is a partially received message pending it will be collected by the next call to any of the io-performing functions. For the callers convenience the Error::Timedout resulting of the EAGAIN/EWOULDBLOCK errors are converted to Ok(()) before returning, since these are expected to happen to normally exit this function.

This will not send automatic error messages for calls to unknown methods because it does never block, but error replies should always be sent. For this reason replies to all filtered calls are collected and returned. The original messages are dropped immediatly, so it should keep memory usage relatively low. The caller is responsible to send these error replies over the RpcConn, at a convenient time.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.