Trait varlink::CallTrait

source ·
pub trait CallTrait {
    fn reply_struct(&mut self, reply: Reply) -> Result<()>;
    fn set_continues(&mut self, cont: bool);
    fn to_upgraded(&mut self);
    fn is_oneway(&self) -> bool;
    fn wants_more(&self) -> bool;
    fn get_request(&self) -> Option<&Request<'_>>;

    fn reply_method_not_found(&mut self, method_name: String) -> Result<()> { ... }
    fn reply_method_not_implemented(&mut self, method_name: String) -> Result<()> { ... }
    fn reply_invalid_parameter(&mut self, parameter_name: String) -> Result<()> { ... }
}
Expand description

CallTrait provides convenience methods for the Call struct, which is passed as the first argument to the interface methods.

Examples

For an invalid parameter:

fn test_method(&self, call: &mut Call_TestMethod, testparam: i64) -> varlink::Result<()> {
   match testparam {
       0 ... 100 => {},
       _ => {
           return call.reply_invalid_parameter("testparam".into());
       }
   }
   /* ... */
   Ok(())
}

For not yet implemented methods:

fn test_method_not_implemented(&self,
                              call: &mut Call_TestMethodNotImplemented) -> varlink::Result<()> {
   return call.reply_method_not_implemented("TestMethodNotImplemented".into());
}

Required Methods§

Don’t use this directly. Rather use the standard reply() method.

Set this to true to indicate, that more replies are following.

Examples
fn test_method(&self, call: &mut Call_TestMethod) -> varlink::Result<()> {
     call.set_continues(true);
     call.reply( /* more args*/ )?;
     call.reply( /* more args*/ )?;
     call.reply( /* more args*/ )?;
     call.set_continues(false);
     return call.reply( /* more args*/ );
 }

True, if this request does not want a reply.

True, if this request accepts more than one reply.

Provided Methods§

reply with the standard varlink org.varlink.service.MethodNotFound error

reply with the standard varlink org.varlink.service.MethodNotImplemented error

reply with the standard varlink org.varlink.service.InvalidParameter error

Implementors§