[][src]Trait varlink::CallTrait

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<()> { ... } }

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

fn reply_struct(&mut self, reply: Reply) -> Result<()>

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

fn set_continues(&mut self, cont: bool)

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*/ );
}

fn to_upgraded(&mut self)

fn is_oneway(&self) -> bool

True, if this request does not want a reply.

fn wants_more(&self) -> bool

True, if this request accepts more than one reply.

fn get_request(&self) -> Option<&Request>

Loading content...

Provided methods

fn reply_method_not_found(&mut self, method_name: String) -> Result<()>

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

fn reply_method_not_implemented(&mut self, method_name: String) -> Result<()>

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

fn reply_invalid_parameter(&mut self, parameter_name: String) -> Result<()>

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

Loading content...

Implementors

impl<'a> CallTrait for Call<'a>[src]

fn is_oneway(&self) -> bool[src]

True, if this request does not want a reply.

fn wants_more(&self) -> bool[src]

True, if this request accepts more than one reply.

fn reply_method_not_found(&mut self, method_name: String) -> Result<()>[src]

fn reply_method_not_implemented(&mut self, method_name: String) -> Result<()>[src]

fn reply_invalid_parameter(&mut self, parameter_name: String) -> Result<()>[src]

Loading content...