pub fn handle(&self, conn: &Connection, msg: &mut Message) -> Option<::std::result::Result<(), ()>> {
        CallHeaders::new(msg).map(|hdrs| {
            let iface_name = hdrs.interface;
            let method_name = hdrs.method;
            let map_ref = &self.map.borrow();
            let opt_iface = map_ref.get(&iface_name);
            let opt_method = opt_iface.and_then(|iface| iface.methods.get(&method_name));

            let res = if let Some(method) = opt_method {
                let res = if Self::_check_signature(&method.in_args, msg) {
                    let mut cb = method.cb.borrow_mut();

                    match cb.deref_mut()(msg) {
                        Ok(vals) => {
                            vals.iter().fold(msg.return_message(), |msg, val| msg.add_argument(val))
                        },
                        Err(err) => err.into_message(msg),
                    }
                } else {
                    Arguments::invalid_arguments().into_message(msg)
                };

                match res.message_type() {
                    MessageType::Error => (),
                    MessageType::MethodReturn => {
                        let expect = Self::_signature(&method.out_args);
                        let actual = Self::_msg_signature(&res);

                        if expect != actual {
                            panic!("invalid return signature for: \
                                    path: '{:?}' interface: '{}' method: '{}' \
                                    expected: '{}' actual: '{}'",
                                   msg.path(),
                                   iface_name,
                                   method_name,
                                   expect,
                                   actual)
                        };
                    },
                    _ => {
                        panic!("invalid return value for: \
                                path: '{:?}' interface: '{}' method: '{}'",
                               msg.path(),
                               iface_name,
                               method_name)
                    },
                };

                res
            } else if opt_iface.is_none() {
                msg.error_message("org.freedesktop.DBus.Error.UnknownMethod")
                    .add_argument(&format!("unknown interface: {}", iface_name))
            } else {
                msg.error_message("org.freedesktop.DBus.Error.UnknownMethod")
                    .add_argument(&format!("unknown method: {}", method_name))
            };

            conn.send(res)
                .map(|_| ())
                .map_err(|_| ())
        })
    }
/// Parse a `Message` and call the appropriate method (if applicable).
///
/// Returns `None` if the method doesn't match, otherwise a a `Result` indicating whether the
/// method call succeeded or not.
///
/// # Panics
///
/// If the method returns values which do not match its signature, a panic will occur since
/// this is a bug in the implementation.
Parse a `Message` and call the appropriate method (if applicable).
Returns `None` if the method doesn't match, otherwise a a `Result` indicating whether the
method call succeeded or not.
Parse a ` Message ` and call the appropriate method ( if applicable ) . Returns ` None ` if the method doesn ' t match otherwise a a ` Result ` indicating whether the method call succeeded or not .
pub fn handle(&self, conn: &Connection, msg: &mut Message) -> Option<::std::result::Result<(), ()>> {
        CallHeaders::new(msg).map(|hdrs| {
            let iface_name = hdrs.interface;
            let method_name = hdrs.method;
            let map_ref = &self.map.borrow();
            let opt_iface = map_ref.get(&iface_name);
            let opt_method = opt_iface.and_then(|iface| iface.methods.get(&method_name));
            let res = if let Some(method) = opt_method {
                let res = if Self::_check_signature(&method.in_args, msg) {
                    let mut cb = method.cb.borrow_mut();
                    match cb.deref_mut()(msg) {
                        Ok(vals) => {
                            vals.iter().fold(msg.return_message(), |msg, val| msg.add_argument(val))
                        },
                        Err(err) => err.into_message(msg),
                    }
                } else {
                    Arguments::invalid_arguments().into_message(msg)
                };
                match res.message_type() {
                    MessageType::Error => (),
                    MessageType::MethodReturn => {
                        let expect = Self::_signature(&method.out_args);
                        let actual = Self::_msg_signature(&res);
                        if expect != actual {
                            panic!("invalid return signature for: \
                                    path: '{:?}' interface: '{}' method: '{}' \
                                    expected: '{}' actual: '{}'",
                                   msg.path(),
                                   iface_name,
                                   method_name,
                                   expect,
                                   actual)
                        };
                    },
                    _ => {
                        panic!("invalid return value for: \
                                path: '{:?}' interface: '{}' method: '{}'",
                               msg.path(),
                               iface_name,
                               method_name)
                    },
                };
                res
            } else if opt_iface.is_none() {
                msg.error_message("org.freedesktop.DBus.Error.UnknownMethod")
                    .add_argument(&format!("unknown interface: {}", iface_name))
            } else {
                msg.error_message("org.freedesktop.DBus.Error.UnknownMethod")
                    .add_argument(&format!("unknown method: {}", method_name))
            };
            conn.send(res)
                .map(|_| ())
                .map_err(|_| ())
        })
    }
pub fn handle ( & self , conn : & Connection , msg : & mut Message ) -> Option < :: std :: result :: Result < ( ) , ( ) > > { CallHeaders :: new ( msg ) . map ( | hdrs | { let iface_name = hdrs . interface ; let method_name = hdrs . method ; let map_ref = & self . map . borrow ( ) ; let opt_iface = map_ref . get ( & iface_name ) ; let opt_method = opt_iface . and_then ( | iface | iface . methods . get ( & method_name ) ) ; let res = if let Some ( method ) = opt_method { let res = if Self :: _check_signature ( & method . in_args , msg ) { let mut cb = method . cb . borrow_mut ( ) ; match cb . deref_mut ( ) ( msg ) { Ok ( vals ) => { vals . iter ( ) . fold ( msg . return_message ( ) , | msg , val | msg . add_argument ( val ) ) } , Err ( err ) => err . into_message ( msg ) , } } else { Arguments :: invalid_arguments ( ) . into_message ( msg ) } ; match res . message_type ( ) { MessageType :: Error => ( ) , MessageType :: MethodReturn => { let expect = Self :: _signature ( & method . out_args ) ; let actual = Self :: _msg_signature ( & res ) ; if expect != actual { panic ! ( " \
 \
 " msg path ( ) iface_name method_name expect actual ) } ; } , _ => { panic ! ( " \
 " msg path ( ) iface_name method_name ) } , } ; res } else if opt_iface . is_none ( ) { msg . error_message ( " " ) . add_argument ( & format ! ( " " iface_name ) ) } else { msg . error_message ( " " ) . add_argument ( & format ! ( " " method_name ) ) } ; conn . send ( res ) . map ( | _ | ( ) ) . map_err ( | _ | ( ) ) } ) }
Parse a `Message` and call the appropriate method (if applicable).
Parse a ` Message ` and call the appropriate method ( if applicable ) .
&self
conn
&Connection
msg
&mut Message
panics
If the method returns values which do not match its signature, a panic will occur since
this is a bug in the implementation.
If the method returns values which do not match its signature a panic will occur since this is a bug in the implementation .