@@ -258,7 +258,7 @@ impl Drop for Introspector {
258
258
///
259
259
/// Please note that this structure can be extended as part of evolutionary API updates at any time
260
260
/// in any new release.
261
- #[ derive( Debug ) ]
261
+ #[ derive( Debug , Clone ) ]
262
262
pub struct SinkPortInfo < ' a > {
263
263
/// Name of this port.
264
264
pub name : Option < Cow < ' a , str > > ,
@@ -324,13 +324,23 @@ impl<'a> SinkPortInfo<'a> {
324
324
}
325
325
}
326
326
}
327
+
328
+ /// Creates owned data from borrowed 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
+ availability_group : self . availability_group . clone ( ) . map ( |o| Cow :: Owned ( o. into_owned ( ) ) ) ,
334
+ ..* self
335
+ }
336
+ }
327
337
}
328
338
329
339
/// Stores information about sinks.
330
340
///
331
341
/// Please note that this structure can be extended as part of evolutionary API updates at any time
332
342
/// in any new release.
333
- #[ derive( Debug ) ]
343
+ #[ derive( Debug , Clone ) ]
334
344
pub struct SinkInfo < ' a > {
335
345
/// Name of the sink.
336
346
pub name : Option < Cow < ' a , str > > ,
@@ -452,6 +462,27 @@ impl<'a> SinkInfo<'a> {
452
462
}
453
463
}
454
464
}
465
+
466
+ /// Creates owned data from borrowed data
467
+ pub fn to_owned ( & self ) -> SinkInfo < ' static > {
468
+ SinkInfo {
469
+ name : self . name . clone ( ) . map ( |o| Cow :: Owned ( o. into_owned ( ) ) ) ,
470
+ description : self . description . clone ( ) . map ( |o| Cow :: Owned ( o. into_owned ( ) ) ) ,
471
+ monitor_source_name : self
472
+ . monitor_source_name
473
+ . clone ( )
474
+ . map ( |o| Cow :: Owned ( o. into_owned ( ) ) ) ,
475
+ driver : self . driver . clone ( ) . map ( |o| Cow :: Owned ( o. into_owned ( ) ) ) ,
476
+ proplist : self . proplist . clone ( ) ,
477
+ ports : self . ports . iter ( ) . map ( SinkPortInfo :: to_owned) . collect ( ) ,
478
+ active_port : self
479
+ . active_port
480
+ . as_ref ( )
481
+ . map ( |spi| Box :: new ( spi. as_ref ( ) . to_owned ( ) ) ) ,
482
+ formats : self . formats . clone ( ) ,
483
+ ..* self
484
+ }
485
+ }
455
486
}
456
487
457
488
impl Introspector {
0 commit comments