[][src]Struct dbus_crossroads::Context

pub struct Context { /* fields omitted */ }

Context is the struct that accompanies you through your method call handler, providing helpful information about the message sent from the client, as well as some methods to send extra messages (typically signals) in return.

Implementations

impl Context[src]

pub fn new(msg: Message) -> Option<Self>[src]

Creates a new Context.

Usually you're not creating your own context, as the crossroads instance is creating one for you.

pub fn check<R, F: FnOnce(&mut Context) -> Result<R, MethodErr>>(
    &mut self,
    f: F
) -> Result<R, ()>
[src]

Convenience method that sets an error reply if the closure returns an error.

pub fn do_reply<F: FnOnce(&mut Message)>(&mut self, f: F)[src]

If the reply is not already set, creates a new method return message and calls the closure so that the closure can fill in the arguments.

pub fn reply<OA: AppendAll>(
    &mut self,
    result: Result<OA, MethodErr>
) -> PhantomData<OA>
[src]

Replies to the incoming message, if the reply is not already set. This is what you'll normally have last in your async method.

Returns PhantomData just to aid the type system.

pub fn set_reply(
    &mut self,
    msg: Option<Message>,
    check_no_reply: bool,
    check_set: bool
)
[src]

Low-level function to set a reply

You should probably prefer do_reply, or reply_ok / reply_err for async methods.

pub fn flush_messages<S: Sender + ?Sized>(&mut self, conn: &S) -> Result<(), ()>[src]

Low-level function to flush set messages

This is called internally, you should probably not use it.

pub fn make_signal<'b, A, N>(&self, name: N, args: A) -> Message where
    A: AppendAll,
    N: Into<Member<'b>>, 
[src]

Makes a new signal with the current interface and path

pub fn push_msg(&mut self, msg: Message)[src]

Adds an extra message to send together with the message reply, e g, a custom signal.

pub fn path(&self) -> &Path<'static>[src]

The current object path.

pub fn interface(&self) -> Option<&Interface<'static>>[src]

The current interface name.

The D-Bus specfication allows for the interface to be unspecified, hence this returns an option. This is very rarely used in practice.

pub fn method(&self) -> &Member<'static>[src]

The current method name.

pub fn message(&self) -> &Message[src]

The message that caused this method to be called.

pub fn has_reply(&self) -> bool[src]

True if a reply (error or method return) has been set.

pub fn has_error(&self) -> bool[src]

Returns true is "reply_err" has been called, or "check" ever returned an error

Trait Implementations

impl Debug for Context[src]

impl Drop for Context[src]

Auto Trait Implementations

impl !RefUnwindSafe for Context

impl Send for Context

impl !Sync for Context

impl Unpin for Context

impl !UnwindSafe for Context

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.