feat(dictionary): make methods accessible from an Owned dictionary

This commit is contained in:
meh
2021-03-20 23:02:36 +01:00
parent 09133a9bad
commit e18f86f7c0
2 changed files with 14 additions and 3 deletions
+3 -1
View File
@@ -25,7 +25,7 @@ impl<'a> Ref<'a> {
}
impl<'a> Ref<'a> {
pub fn set(&mut self, key: &str, value: &str) {
pub fn set(&mut self, key: &str, value: &str) -> &mut Self {
unsafe {
let key = CString::new(key).unwrap();
let value = CString::new(value).unwrap();
@@ -38,6 +38,8 @@ impl<'a> Ref<'a> {
self.ptr = ptr;
self.imm = immutable::Ref::wrap(ptr);
}
self
}
}
+11 -2
View File
@@ -24,11 +24,11 @@ impl Owned {
result
}
pub fn as_ptr(&self) -> *const AVDictionary {
pub unsafe fn as_ptr(&self) -> *const AVDictionary {
self.ptr
}
pub fn as_mut_ptr(&mut self) -> *mut AVDictionary {
pub unsafe fn as_mut_ptr(&mut self) -> *mut AVDictionary {
self.ptr
}
}
@@ -47,6 +47,15 @@ impl Owned {
pub fn as_mut(&self) -> mutable::Ref {
unsafe { mutable::Ref::wrap(self.ptr) }
}
pub fn iter(&self) -> Iter<'_> {
unsafe { Iter::new(self.as_ptr()) }
}
pub fn set(&mut self, key: &str, value: &str) -> &mut Self {
self.as_mut().set(key, value);
self
}
}
impl<'a> FromIterator<(&'a str, &'a str)> for Owned {