Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions pulse-binding/src/context/introspect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,17 @@ impl<'a> SinkPortInfo<'a> {
}
}
}

/// Creates a copy with owned data.
pub fn to_owned(&self) -> SinkPortInfo<'static> {
SinkPortInfo {
name: self.name.clone().map(|o| Cow::Owned(o.into_owned())),
description: self.description.clone().map(|o| Cow::Owned(o.into_owned())),
#[cfg(any(doc, feature = "pa_v14"))]
availability_group: self.availability_group.clone().map(|o| Cow::Owned(o.into_owned())),
..*self
}
}
}

/// Stores information about sinks.
Expand Down Expand Up @@ -452,6 +463,27 @@ impl<'a> SinkInfo<'a> {
}
}
}

/// Creates owned data from borrowed data
pub fn to_owned(&self) -> SinkInfo<'static> {
SinkInfo {
name: self.name.clone().map(|o| Cow::Owned(o.into_owned())),
description: self.description.clone().map(|o| Cow::Owned(o.into_owned())),
monitor_source_name: self
.monitor_source_name
.clone()
.map(|o| Cow::Owned(o.into_owned())),
driver: self.driver.clone().map(|o| Cow::Owned(o.into_owned())),
proplist: self.proplist.clone(),
ports: self.ports.iter().map(SinkPortInfo::to_owned).collect(),
active_port: self
.active_port
.as_ref()
.map(|spi| Box::new(spi.as_ref().to_owned())),
formats: self.formats.clone(),
..*self
}
}
}

impl Introspector {
Expand Down Expand Up @@ -725,6 +757,17 @@ impl<'a> SourcePortInfo<'a> {
}
}
}

/// Creates a copy with owned data.
pub fn to_owned(&self) -> SourcePortInfo<'static> {
SourcePortInfo {
name: self.name.clone().map(|o| Cow::Owned(o.into_owned())),
description: self.description.clone().map(|o| Cow::Owned(o.into_owned())),
#[cfg(any(doc, feature = "pa_v14"))]
availability_group: self.availability_group.clone().map(|o| Cow::Owned(o.into_owned())),
..*self
}
}
}

/// Stores information about sources.
Expand Down Expand Up @@ -1123,6 +1166,19 @@ impl<'a> ServerInfo<'a> {
}
}
}

/// Creates a copy with owned data.
pub fn to_owned(&self) -> ServerInfo<'static> {
ServerInfo {
user_name: self.user_name.clone().map(|o| Cow::Owned(o.into_owned())),
host_name: self.host_name.clone().map(|o| Cow::Owned(o.into_owned())),
server_version: self.server_version.clone().map(|o| Cow::Owned(o.into_owned())),
server_name: self.server_name.clone().map(|o| Cow::Owned(o.into_owned())),
default_sink_name: self.default_sink_name.clone().map(|o| Cow::Owned(o.into_owned())),
default_source_name: self.default_source_name.clone().map(|o| Cow::Owned(o.into_owned())),
..*self
}
}
}

impl Introspector {
Expand Down Expand Up @@ -1503,6 +1559,15 @@ impl<'a> CardProfileInfo<'a> {
}
}
}

/// Creates a copy with owned data.
pub fn to_owned(&self) -> CardProfileInfo<'static> {
CardProfileInfo {
name: self.name.clone().map(|o| Cow::Owned(o.into_owned())),
description: self.description.clone().map(|o| Cow::Owned(o.into_owned())),
..*self
}
}
}

/// Stores information about a specific port of a card.
Expand Down