Struct dbus_crossroads::Context
source · [−]pub struct Context { /* private fields */ }
Expand description
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
sourceimpl Context
impl Context
sourcepub fn new(msg: Message) -> Option<Self>
pub fn new(msg: Message) -> Option<Self>
Creates a new Context.
Usually you’re not creating your own context, as the crossroads instance is creating one for you.
sourcepub fn check<R, F: FnOnce(&mut Context) -> Result<R, MethodErr>>(
&mut self,
f: F
) -> Result<R, ()>
pub fn check<R, F: FnOnce(&mut Context) -> Result<R, MethodErr>>(
&mut self,
f: F
) -> Result<R, ()>
Convenience method that sets an error reply if the closure returns an error.
sourcepub fn do_reply<F: FnOnce(&mut Message)>(&mut self, f: F)
pub fn do_reply<F: FnOnce(&mut Message)>(&mut self, f: F)
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.
sourcepub fn reply<OA: AppendAll>(
&mut self,
result: Result<OA, MethodErr>
) -> PhantomData<OA>
pub fn reply<OA: AppendAll>(
&mut self,
result: Result<OA, MethodErr>
) -> PhantomData<OA>
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.
sourcepub fn set_reply(
&mut self,
msg: Option<Message>,
check_no_reply: bool,
check_set: bool
)
pub fn set_reply(
&mut self,
msg: Option<Message>,
check_no_reply: bool,
check_set: bool
)
Low-level function to set a reply
You should probably prefer do_reply, or reply_ok / reply_err for async methods.
sourcepub fn flush_messages<S: Sender + ?Sized>(&mut self, conn: &S) -> Result<(), ()>
pub fn flush_messages<S: Sender + ?Sized>(&mut self, conn: &S) -> Result<(), ()>
Low-level function to flush set messages
This is called internally, you should probably not use it.
sourcepub fn make_signal<'b, A, N>(&self, name: N, args: A) -> Messagewhere
A: AppendAll,
N: Into<Member<'b>>,
pub fn make_signal<'b, A, N>(&self, name: N, args: A) -> Messagewhere
A: AppendAll,
N: Into<Member<'b>>,
Makes a new signal with the current interface and path
sourcepub fn push_msg(&mut self, msg: Message)
pub fn push_msg(&mut self, msg: Message)
Adds an extra message to send together with the message reply, e g, a custom signal.