Address a number of clippy complaints

This commit is contained in:
2020-05-16 14:51:41 +01:00
parent 33d522779a
commit 640948241a
4 changed files with 20 additions and 20 deletions

View File

@@ -43,8 +43,8 @@ fn run() -> Result<()> {
let mut c = LocalConnection::new_session()?; let mut c = LocalConnection::new_session()?;
tree.start_receive(&c); tree.start_receive(&c);
for name in vec![CM_BUS_NAME, PROTO_BUS_NAME, CM_CONN_BUS_NAME, CONN_BUS_NAME] { for name in &[CM_BUS_NAME, PROTO_BUS_NAME, CM_CONN_BUS_NAME, CONN_BUS_NAME] {
let result = c.request_name(name, false, false, true)?; let result = c.request_name(*name, false, false, true)?;
match result { match result {
RequestNameReply::Exists => { RequestNameReply::Exists => {
return Err(anyhow!("Another process is already registered on {}", name)) return Err(anyhow!("Another process is already registered on {}", name))

View File

@@ -1,6 +1,7 @@
mod avatars; mod avatars;
pub use self::avatars::*; pub use self::avatars::*;
#[allow(clippy::module_inception)]
mod connection; mod connection;
pub use self::connection::*; pub use self::connection::*;
@@ -69,7 +70,7 @@ impl Connection {
}; };
let mut dbfile = directories::ProjectDirs::from("gs", "ur", "telepathy-padfoot") let mut dbfile = directories::ProjectDirs::from("gs", "ur", "telepathy-padfoot")
.ok_or(MethodErr::no_arg()) .ok_or_else(MethodErr::no_arg)
.and_then(|p| Ok(p.data_local_dir().to_path_buf()))?; .and_then(|p| Ok(p.data_local_dir().to_path_buf()))?;
dbfile.push(&id); dbfile.push(&id);
@@ -137,9 +138,9 @@ impl Connection {
Ok(Connection { Ok(Connection {
id, id,
msgq,
ctx: Arc::new(RwLock::new(ctx)), ctx: Arc::new(RwLock::new(ctx)),
state: Arc::new(RwLock::new(ConnState::Initial)), state: Arc::new(RwLock::new(ConnState::Initial)),
msgq: msgq.clone(),
}) })
} }
@@ -177,12 +178,11 @@ impl Connection {
let requests_iface = let requests_iface =
telepathy::connection_interface_requests_server(&f, (), move |_| c_rc5.clone()); telepathy::connection_interface_requests_server(&f, (), move |_| c_rc5.clone());
let c_rc6 = c_rc.clone();
let simple_presence_iface = let simple_presence_iface =
telepathy::connection_interface_simple_presence_server(&f, (), move |_| c_rc6.clone()); telepathy::connection_interface_simple_presence_server(&f, (), move |_| c_rc.clone());
tree = tree.add( tree = tree.add(
f.object_path(path.clone(), ()) f.object_path(path, ())
.introspectable() .introspectable()
.add(conn_iface) .add(conn_iface)
.add(avatars_iface) .add(avatars_iface)
@@ -223,18 +223,14 @@ impl Connection {
println!("Error processing: {}", e); println!("Error processing: {}", e);
return; return;
} };
// Spend a bit of time sending any outgoing messages - signals, mostly // Spend a bit of time sending any outgoing messages - signals, mostly
loop { while let Some(msg) = msgq.lock().unwrap().pop_front() {
let msg = match msgq.lock().unwrap().pop_front() {
Some(msg) => msg,
None => break,
};
print!("Connection<{}>: Sending message...", id); print!("Connection<{}>: Sending message...", id);
match c.send(msg) { match c.send(msg) {
Err(e) => println!("error! {:?}", e), Err(e) => println!("error! {:?}", e), // FIXME: handle error better?
_ => println!("OK!"), _ => println!("OK!"),
} }
} }

View File

@@ -11,9 +11,11 @@ impl AsRef<dyn telepathy::ConnectionInterfaceAvatars + 'static> for std::rc::Rc<
} }
} }
type AvatarRequirementSpec = (Vec<String>, u16, u16, u16, u16, u32);
// TODO: come back and do this properly, I'm just putting it in for consistency // TODO: come back and do this properly, I'm just putting it in for consistency
impl telepathy::ConnectionInterfaceAvatars for Connection { impl telepathy::ConnectionInterfaceAvatars for Connection {
fn get_avatar_requirements(&self) -> Result<(Vec<String>, u16, u16, u16, u16, u32), MethodErr> { fn get_avatar_requirements(&self) -> Result<AvatarRequirementSpec, MethodErr> {
println!("Connection<{}>::get_avatar_requirements()", self.id); println!("Connection<{}>::get_avatar_requirements()", self.id);
Ok((vec![], 0, 0, 0, 0, 0)) Ok((vec![], 0, 0, 0, 0, 0))
} }

View File

@@ -15,6 +15,10 @@ impl AsRef<dyn telepathy::ConnectionInterfaceRequests + 'static> for std::rc::Rc
} }
} }
type ChannelSpec = (dbus::Path<'static>, HashMap<String, VarArg>);
type RequestableChannelSpec = (HashMap<String, VarArg>, Vec<String>);
impl telepathy::ConnectionInterfaceRequests for Connection { impl telepathy::ConnectionInterfaceRequests for Connection {
fn create_channel( fn create_channel(
&self, &self,
@@ -33,14 +37,12 @@ impl telepathy::ConnectionInterfaceRequests for Connection {
Err(MethodErr::no_arg()) // FIXME: should be NotImplemented? Err(MethodErr::no_arg()) // FIXME: should be NotImplemented?
} }
fn channels(&self) -> Result<Vec<(dbus::Path<'static>, HashMap<String, VarArg>)>, MethodErr> { fn channels(&self) -> Result<Vec<ChannelSpec>, MethodErr> {
println!("Connection<{}>::channels()", self.id); println!("Connection<{}>::channels()", self.id);
Ok(vec![]) Ok(vec![])
} }
fn requestable_channel_classes( fn requestable_channel_classes(&self) -> Result<Vec<RequestableChannelSpec>, MethodErr> {
&self,
) -> Result<Vec<(HashMap<String, VarArg>, Vec<String>)>, MethodErr> {
println!("Connection<{}>::requestable_channel_classes()", self.id); println!("Connection<{}>::requestable_channel_classes()", self.id);
Ok(crate::padfoot::requestables()) Ok(crate::padfoot::requestables())
} }