fix clippy warnings

This commit is contained in:
Guillaume Desmottes
2021-02-03 16:18:59 +01:00
committed by Tom A. Wagner
parent 99b2ef274a
commit 5784275d32
4 changed files with 24 additions and 22 deletions

View File

@@ -49,7 +49,7 @@ impl PipewireConnection {
.register(); .register();
Ok(Self { Ok(Self {
mainloop: mainloop, mainloop,
_context: context, _context: context,
core, core,
_registry: registry, _registry: registry,

View File

@@ -40,12 +40,10 @@ pub struct PipewireState {
impl PipewireState { impl PipewireState {
pub fn new(graphview: Rc<RefCell<view::GraphView>>) -> Self { pub fn new(graphview: Rc<RefCell<view::GraphView>>) -> Self {
let result = Self { Self {
graphview, graphview,
items: HashMap::new(), items: HashMap::new(),
}; }
result
} }
/// This function is called from the `PipewireConnection` struct responsible for updating this struct. /// This function is called from the `PipewireConnection` struct responsible for updating this struct.
@@ -66,18 +64,20 @@ impl PipewireState {
fn add_node(&mut self, node: GlobalObject) { fn add_node(&mut self, node: GlobalObject) {
// Update graph to contain the new node. // Update graph to contain the new node.
let node_widget = crate::view::Node::new(&format!( let node_widget = crate::view::Node::new(
"{}", &node
node.props .props
.as_ref() .as_ref()
.map(|dict| String::from( .map(|dict| {
dict.get("node.nick") String::from(
.or(dict.get("node.description")) dict.get("node.nick")
.or(dict.get("node.name")) .or_else(|| dict.get("node.description"))
.unwrap_or_default() .or_else(|| dict.get("node.name"))
)) .unwrap_or_default(),
.unwrap_or_default() )
)); })
.unwrap_or_default(),
);
// FIXME: This relies on the node being passed to us by the pipwire server before its port. // FIXME: This relies on the node being passed to us by the pipwire server before its port.
let media_type = node let media_type = node
@@ -115,7 +115,7 @@ impl PipewireState {
fn add_port(&mut self, port: GlobalObject) { fn add_port(&mut self, port: GlobalObject) {
// Update graph to contain the new port. // Update graph to contain the new port.
let props = port.props.expect("Port object is missing properties"); let props = port.props.expect("Port object is missing properties");
let port_label = format!("{}", props.get("port.name").unwrap_or_default()); let port_label = props.get("port.name").unwrap_or_default().to_string();
let node_id: u32 = props let node_id: u32 = props
.get("node.id") .get("node.id")
.expect("Port has no node.id property!") .expect("Port has no node.id property!")

View File

@@ -273,3 +273,9 @@ impl GraphView {
self.queue_draw(); self.queue_draw();
} }
} }
impl Default for GraphView {
fn default() -> Self {
Self::new()
}
}

View File

@@ -135,11 +135,7 @@ impl Node {
pub fn get_port(&self, id: u32) -> Option<Rc<super::port::Port>> { pub fn get_port(&self, id: u32) -> Option<Rc<super::port::Port>> {
let private = imp::Node::from_instance(self); let private = imp::Node::from_instance(self);
private private.ports.borrow_mut().get(&id).cloned()
.ports
.borrow_mut()
.get(&id)
.map(|port_rc| port_rc.clone())
} }
pub fn remove_port(&self, id: u32) { pub fn remove_port(&self, id: u32) {