Trait varlink::CallTrait [] [src]

pub trait CallTrait {
    fn reply_struct(&mut self, reply: Reply) -> Result<()>;
fn set_continues(&mut self, cont: bool); fn reply_method_not_found(
        &mut self,
        method_name: Option<String>
    ) -> Result<()> { ... }
fn reply_method_not_implemented(
        &mut self,
        method_name: Option<String>
    ) -> Result<()> { ... }
fn reply_invalid_parameter(
        &mut self,
        parameter_name: Option<String>
    ) -> Result<()> { ... } }

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 _CallTestMethod, testparam: Option<i64>) -> io::Result<()> {
   match testparam {
       Some(i) => if i > 100 {
           return call.reply_invalid_parameter(Some("testparam".into()));
       },
       None => {
           return call.reply_invalid_parameter(Some("testparam".into()));
       }
   }
   /* ... */
   Ok(())
}

For not yet implemented methods:

fn test_method_not_implemented(&self,
                              call: &mut _CallTestMethodNotImplemented) -> io::Result<()> {
   return call.reply_method_not_implemented(Some("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 _CallTestMethod) -> io::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*/ );
}

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