Skip to content

Commit 85d0914

Browse files
committed
introspect: add to_owned functions to SinkInfo
1 parent d8bbde3 commit 85d0914

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

pulse-binding/src/context/introspect.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,27 @@ impl<'a> SinkInfo<'a> {
463463
}
464464
}
465465
}
466+
467+
/// Creates owned data from borrowed data
468+
pub fn to_owned(&self) -> SinkInfo<'static> {
469+
SinkInfo {
470+
name: self.name.clone().map(|o| Cow::Owned(o.into_owned())),
471+
description: self.description.clone().map(|o| Cow::Owned(o.into_owned())),
472+
monitor_source_name: self
473+
.monitor_source_name
474+
.clone()
475+
.map(|o| Cow::Owned(o.into_owned())),
476+
driver: self.driver.clone().map(|o| Cow::Owned(o.into_owned())),
477+
proplist: self.proplist.clone(),
478+
ports: self.ports.iter().map(SinkPortInfo::to_owned).collect(),
479+
active_port: self
480+
.active_port
481+
.as_ref()
482+
.map(|spi| Box::new(spi.as_ref().to_owned())),
483+
formats: self.formats.clone(),
484+
..*self
485+
}
486+
}
466487
}
467488

468489
impl Introspector {

0 commit comments

Comments
 (0)