Files
telepathy-padfoot/src/telepathy/channel_interface_chat_state.rs
Nick Thomas 3d44ce6b3d Initial checkin
This commit contains autogenerated telepathy DBUS code and the output
of `cargo new telepathy-delta`. It's pretty chill.
2020-05-08 20:38:30 +01:00

86 lines
2.8 KiB
Rust

// This code was autogenerated with `dbus-codegen-rust --file telepathy-spec/spec/Channel_Interface_Chat_State.xml -i org.freedesktop.Telepathy -o src/telepathy/channel_interface_chat_state.rs`, see https://github.com/diwic/dbus-rs
use dbus;
use dbus::arg;
use dbus::tree;
pub trait ChannelInterfaceChatState {
fn set_chat_state(&self, state: u32) -> Result<(), tree::MethodErr>;
fn chat_states(&self) -> Result<::std::collections::HashMap<u32, u32>, tree::MethodErr>;
}
pub fn channel_interface_chat_state_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,
T: ChannelInterfaceChatState,
F: 'static + for<'z> Fn(&'z tree::MethodInfo<tree::MTFn<D>, D>) -> &'z T,
{
let i = factory.interface(
"org.freedesktop.Telepathy.Channel.Interface.ChatState",
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 state: u32 = i.read()?;
let d = fclone(minfo);
d.set_chat_state(state)?;
let rm = minfo.msg.method_return();
Ok(vec![rm])
};
let m = factory.method("SetChatState", Default::default(), h);
let m = m.in_arg(("State", "u"));
let i = i.add_m(m);
let p = factory
.property::<::std::collections::HashMap<u32, u32>, _>("ChatStates", 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();
let d = fclone(&minfo);
a.append(d.chat_states()?);
Ok(())
});
let i = i.add_p(p);
let s = factory.signal("ChatStateChanged", Default::default());
let s = s.arg(("Contact", "u"));
let s = s.arg(("State", "u"));
let i = i.add_s(s);
i
}
#[derive(Debug)]
pub struct ChannelInterfaceChatStateChatStateChanged {
pub contact: u32,
pub state: u32,
}
impl arg::AppendAll for ChannelInterfaceChatStateChatStateChanged {
fn append(&self, i: &mut arg::IterAppend) {
arg::RefArg::append(&self.contact, i);
arg::RefArg::append(&self.state, i);
}
}
impl arg::ReadAll for ChannelInterfaceChatStateChatStateChanged {
fn read(i: &mut arg::Iter) -> Result<Self, arg::TypeMismatchError> {
Ok(ChannelInterfaceChatStateChatStateChanged {
contact: i.read()?,
state: i.read()?,
})
}
}
impl dbus::message::SignalArgs for ChannelInterfaceChatStateChatStateChanged {
const NAME: &'static str = "ChatStateChanged";
const INTERFACE: &'static str = "org.freedesktop.Telepathy.Channel.Interface.ChatState";
}