2020-05-11 00:48:18 +01:00
// This code was autogenerated with `dbus-codegen-rust --file telepathy-spec/spec/Connection_Interface_Forwarding.xml -i org.freedesktop.Telepathy -a AsRefClosure -o src/telepathy/connection_interface_forwarding.rs`, see https://github.com/diwic/dbus-rs
2020-05-08 20:38:30 +01:00
use dbus ;
use dbus ::arg ;
use dbus ::tree ;
pub trait ConnectionInterfaceForwardingDRAFT {
fn set_forwarding_rule (
& self ,
condition : u32 ,
forwards : Vec < ( u32 , u32 ) > ,
) -> Result < Vec < ( u32 , u32 ) > , tree ::MethodErr > ;
fn supported_forwarding_conditions (
& self ,
) -> Result < ::std ::collections ::HashMap < u32 , u32 > , tree ::MethodErr > ;
fn forwarding_rules (
& self ,
) -> Result < ::std ::collections ::HashMap < u32 , ( u32 , Vec < ( u32 , u32 ) > ) > , tree ::MethodErr > ;
}
pub fn connection_interface_forwarding_draft_server < F , T , D > (
factory : & tree ::Factory < tree ::MTFn < D > , D > ,
data : D ::Interface ,
f : F ,
) -> tree ::Interface < tree ::MTFn < D > , D >
where
D : tree ::DataType ,
D ::Method : Default ,
D ::Property : Default ,
D ::Signal : Default ,
2020-05-11 00:48:18 +01:00
T : AsRef < dyn ConnectionInterfaceForwardingDRAFT > ,
F : 'static + Fn ( & tree ::MethodInfo < tree ::MTFn < D > , D > ) -> T ,
2020-05-08 20:38:30 +01:00
{
let i = factory . interface (
" org.freedesktop.Telepathy.Connection.Interface.Forwarding.DRAFT " ,
data ,
) ;
let f = ::std ::sync ::Arc ::new ( f ) ;
let fclone = f . clone ( ) ;
let h = move | minfo : & tree ::MethodInfo < tree ::MTFn < D > , D > | {
let mut i = minfo . msg . iter_init ( ) ;
let condition : u32 = i . read ( ) ? ;
let forwards : Vec < ( u32 , u32 ) > = i . read ( ) ? ;
2020-05-11 00:48:18 +01:00
let dd = fclone ( minfo ) ;
let d = dd . as_ref ( ) ;
2020-05-08 20:38:30 +01:00
let old_forwards = d . set_forwarding_rule ( condition , forwards ) ? ;
let rm = minfo . msg . method_return ( ) ;
let rm = rm . append1 ( old_forwards ) ;
Ok ( vec! [ rm ] )
} ;
let m = factory . method ( " SetForwardingRule " , Default ::default ( ) , h ) ;
let m = m . in_arg ( ( " Condition " , " u " ) ) ;
let m = m . in_arg ( ( " Forwards " , " a(uu) " ) ) ;
let m = m . out_arg ( ( " Old_Forwards " , " a(uu) " ) ) ;
let i = i . add_m ( m ) ;
let p = factory . property ::< ::std ::collections ::HashMap < u32 , u32 > , _ > (
" SupportedForwardingConditions " ,
Default ::default ( ) ,
) ;
let p = p . access ( tree ::Access ::Read ) ;
let fclone = f . clone ( ) ;
let p = p . on_get ( move | a , pinfo | {
let minfo = pinfo . to_method_info ( ) ;
2020-05-11 00:48:18 +01:00
let dd = fclone ( & minfo ) ;
let d = dd . as_ref ( ) ;
2020-05-08 20:38:30 +01:00
a . append ( d . supported_forwarding_conditions ( ) ? ) ;
Ok ( ( ) )
} ) ;
let i = i . add_p ( p ) ;
let p = factory . property ::< ::std ::collections ::HashMap < u32 , ( u32 , Vec < ( u32 , u32 ) > ) > , _ > (
" ForwardingRules " ,
Default ::default ( ) ,
) ;
let p = p . access ( tree ::Access ::Read ) ;
let fclone = f . clone ( ) ;
let p = p . on_get ( move | a , pinfo | {
let minfo = pinfo . to_method_info ( ) ;
2020-05-11 00:48:18 +01:00
let dd = fclone ( & minfo ) ;
let d = dd . as_ref ( ) ;
2020-05-08 20:38:30 +01:00
a . append ( d . forwarding_rules ( ) ? ) ;
Ok ( ( ) )
} ) ;
let i = i . add_p ( p ) ;
let s = factory . signal ( " ForwardingRuleChanged " , Default ::default ( ) ) ;
let s = s . arg ( ( " Condition " , " u " ) ) ;
let s = s . arg ( ( " Timeout " , " u " ) ) ;
let s = s . arg ( ( " Forwards " , " a(uu) " ) ) ;
let i = i . add_s ( s ) ;
i
}
#[ derive(Debug) ]
pub struct ConnectionInterfaceForwardingDRAFTForwardingRuleChanged {
pub condition : u32 ,
pub timeout : u32 ,
pub forwards : Vec < ( u32 , u32 ) > ,
}
impl arg ::AppendAll for ConnectionInterfaceForwardingDRAFTForwardingRuleChanged {
fn append ( & self , i : & mut arg ::IterAppend ) {
arg ::RefArg ::append ( & self . condition , i ) ;
arg ::RefArg ::append ( & self . timeout , i ) ;
arg ::RefArg ::append ( & self . forwards , i ) ;
}
}
impl arg ::ReadAll for ConnectionInterfaceForwardingDRAFTForwardingRuleChanged {
fn read ( i : & mut arg ::Iter ) -> Result < Self , arg ::TypeMismatchError > {
Ok ( ConnectionInterfaceForwardingDRAFTForwardingRuleChanged {
condition : i . read ( ) ? ,
timeout : i . read ( ) ? ,
forwards : i . read ( ) ? ,
} )
}
}
impl dbus ::message ::SignalArgs for ConnectionInterfaceForwardingDRAFTForwardingRuleChanged {
const NAME : & 'static str = " ForwardingRuleChanged " ;
const INTERFACE : & 'static str =
" org.freedesktop.Telepathy.Connection.Interface.Forwarding.DRAFT " ;
}