File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -412,7 +412,10 @@ extern "C" {
412412 ) -> Status ;
413413}
414414
415- pub fn get_property ( path : Vec < & str > ) -> Result < Option < Bytes > , Status > {
415+ pub fn get_property < ' a , P > ( path : P ) -> Result < Option < Bytes > , Status >
416+ where
417+ P : AsRef < [ & ' a str ] > ,
418+ {
416419 let serialized_path = utils:: serialize_property_path ( path) ;
417420 let mut return_data: * mut u8 = null_mut ( ) ;
418421 let mut return_size: usize = 0 ;
@@ -451,7 +454,10 @@ extern "C" {
451454 ) -> Status ;
452455}
453456
454- pub fn set_property ( path : Vec < & str > , value : Option < & [ u8 ] > ) -> Result < ( ) , Status > {
457+ pub fn set_property < ' a , P > ( path : P , value : Option < & [ u8 ] > ) -> Result < ( ) , Status >
458+ where
459+ P : AsRef < [ & ' a str ] > ,
460+ {
455461 let serialized_path = utils:: serialize_property_path ( path) ;
456462 unsafe {
457463 match proxy_set_property (
@@ -1208,16 +1214,21 @@ mod utils {
12081214 use crate :: types:: Bytes ;
12091215 use std:: convert:: TryFrom ;
12101216
1211- pub ( super ) fn serialize_property_path ( path : Vec < & str > ) -> Bytes {
1217+ pub ( super ) fn serialize_property_path < ' a , P > ( path : P ) -> Bytes
1218+ where
1219+ P : AsRef < [ & ' a str ] > ,
1220+ {
1221+ let path = path. as_ref ( ) ;
1222+
12121223 if path. is_empty ( ) {
12131224 return Vec :: new ( ) ;
12141225 }
12151226 let mut size: usize = 0 ;
1216- for part in & path {
1227+ for & part in path {
12171228 size += part. len ( ) + 1 ;
12181229 }
12191230 let mut bytes: Bytes = Vec :: with_capacity ( size) ;
1220- for part in & path {
1231+ for & part in path {
12211232 bytes. extend_from_slice ( part. as_bytes ( ) ) ;
12221233 bytes. push ( 0 ) ;
12231234 }
You can’t perform that action at this time.
0 commit comments