Skip to content

Commit d8bbde3

Browse files
committed
enable cloning of some introspection structs
other structs have problematic attributes of types like Proplist which will require more work.
1 parent 2881836 commit d8bbde3

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

pulse-binding/src/context/introspect.rs

+44
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,17 @@ impl<'a> SinkPortInfo<'a> {
324324
}
325325
}
326326
}
327+
328+
/// Creates a copy with owned data.
329+
pub fn to_owned(&self) -> SinkPortInfo<'static> {
330+
SinkPortInfo {
331+
name: self.name.clone().map(|o| Cow::Owned(o.into_owned())),
332+
description: self.description.clone().map(|o| Cow::Owned(o.into_owned())),
333+
#[cfg(any(doc, feature = "pa_v14"))]
334+
availability_group: self.availability_group.clone().map(|o| Cow::Owned(o.into_owned())),
335+
..*self
336+
}
337+
}
327338
}
328339

329340
/// Stores information about sinks.
@@ -725,6 +736,17 @@ impl<'a> SourcePortInfo<'a> {
725736
}
726737
}
727738
}
739+
740+
/// Creates a copy with owned data.
741+
pub fn to_owned(&self) -> SourcePortInfo<'static> {
742+
SourcePortInfo {
743+
name: self.name.clone().map(|o| Cow::Owned(o.into_owned())),
744+
description: self.description.clone().map(|o| Cow::Owned(o.into_owned())),
745+
#[cfg(any(doc, feature = "pa_v14"))]
746+
availability_group: self.availability_group.clone().map(|o| Cow::Owned(o.into_owned())),
747+
..*self
748+
}
749+
}
728750
}
729751

730752
/// Stores information about sources.
@@ -1123,6 +1145,19 @@ impl<'a> ServerInfo<'a> {
11231145
}
11241146
}
11251147
}
1148+
1149+
/// Creates a copy with owned data.
1150+
pub fn to_owned(&self) -> ServerInfo<'static> {
1151+
ServerInfo {
1152+
user_name: self.user_name.clone().map(|o| Cow::Owned(o.into_owned())),
1153+
host_name: self.host_name.clone().map(|o| Cow::Owned(o.into_owned())),
1154+
server_version: self.server_version.clone().map(|o| Cow::Owned(o.into_owned())),
1155+
server_name: self.server_name.clone().map(|o| Cow::Owned(o.into_owned())),
1156+
default_sink_name: self.default_sink_name.clone().map(|o| Cow::Owned(o.into_owned())),
1157+
default_source_name: self.default_source_name.clone().map(|o| Cow::Owned(o.into_owned())),
1158+
..*self
1159+
}
1160+
}
11261161
}
11271162

11281163
impl Introspector {
@@ -1503,6 +1538,15 @@ impl<'a> CardProfileInfo<'a> {
15031538
}
15041539
}
15051540
}
1541+
1542+
/// Creates a copy with owned data.
1543+
pub fn to_owned(&self) -> CardProfileInfo<'static> {
1544+
CardProfileInfo {
1545+
name: self.name.clone().map(|o| Cow::Owned(o.into_owned())),
1546+
description: self.description.clone().map(|o| Cow::Owned(o.into_owned())),
1547+
..*self
1548+
}
1549+
}
15061550
}
15071551

15081552
/// Stores information about a specific port of a card.

0 commit comments

Comments
 (0)