pub struct Parser<'d> { /* private fields */ }
Expand description
Low-level wrapper around spa_pod_parser
.
Using this may require using unsafe
and/or working with C types, but
is still more safe and rusty than the raw functions and types.
Implementations§
source§impl<'d> Parser<'d>
impl<'d> Parser<'d>
pub fn new(data: &'d [u8]) -> Self
pub fn from_pod(pod: &'d Pod) -> Self
pub fn as_raw(&self) -> &spa_pod_parser
pub fn as_raw_ptr(&self) -> *mut spa_pod_parser
pub fn into_raw(self) -> spa_pod_parser
sourcepub unsafe fn state(&self) -> spa_pod_parser_state
pub unsafe fn state(&self) -> spa_pod_parser_state
§Safety
The parser state may only be used as long as all frames that were pushed to the parser at the time of this call are alive and not moved
sourcepub unsafe fn reset(&mut self, state: *mut spa_pod_parser_state)
pub unsafe fn reset(&mut self, state: *mut spa_pod_parser_state)
§Safety
TODO: Constraints unknown, use at own risk
sourcepub unsafe fn deref(&mut self, offset: u32, size: u32) -> *mut spa_pod
pub unsafe fn deref(&mut self, offset: u32, size: u32) -> *mut spa_pod
§Safety
TODO: Constraints unknown, use at own risk
sourcepub unsafe fn frame(&mut self, frame: *mut spa_pod_frame) -> *mut spa_pod
pub unsafe fn frame(&mut self, frame: *mut spa_pod_frame) -> *mut spa_pod
§Safety
TODO: Constraints unknown, use at own risk
sourcepub unsafe fn push(
&mut self,
frame: *mut spa_pod_frame,
pod: *const spa_pod,
offset: u32
)
pub unsafe fn push( &mut self, frame: *mut spa_pod_frame, pod: *const spa_pod, offset: u32 )
§Safety
TODO: Constraints unknown, use at own risk
pub fn current(&mut self) -> *mut spa_pod
sourcepub unsafe fn advance(&mut self, pod: *const spa_pod)
pub unsafe fn advance(&mut self, pod: *const spa_pod)
§Safety
Pod pointed to must we valid, well aligned, and contained in the current frame
TODO: Any other constraints? Use at own risk
sourcepub unsafe fn next(&mut self) -> *mut spa_pod
pub unsafe fn next(&mut self) -> *mut spa_pod
§Safety
TODO: Constraints unknown, use at own risk
sourcepub unsafe fn pop(&mut self, frame: &mut spa_pod_frame) -> Result<(), Errno>
pub unsafe fn pop(&mut self, frame: &mut spa_pod_frame) -> Result<(), Errno>
§Safety
Only the last added frame may be popped
pub fn get_bool(&mut self) -> Result<bool, Errno>
pub fn get_id(&mut self) -> Result<Id, Errno>
pub fn get_int(&mut self) -> Result<i32, Errno>
pub fn get_long(&mut self) -> Result<i64, Errno>
pub fn get_float(&mut self) -> Result<c_float, Errno>
pub fn get_double(&mut self) -> Result<c_double, Errno>
pub fn get_string_raw(&mut self) -> Result<&'d CStr, Errno>
pub fn get_bytes(&mut self) -> Result<&'d [u8], Errno>
pub fn get_pointer(&mut self) -> Result<(*const c_void, Id), Errno>
pub fn get_fd(&mut self) -> Result<i64, Errno>
pub fn get_rectangle(&mut self) -> Result<Rectangle, Errno>
pub fn get_fraction(&mut self) -> Result<Fraction, Errno>
pub fn get_pod(&mut self) -> Result<&'d Pod, Errno>
sourcepub unsafe fn push_struct(
&mut self,
frame: &mut MaybeUninit<spa_pod_frame>
) -> Result<(), Errno>
pub unsafe fn push_struct( &mut self, frame: &mut MaybeUninit<spa_pod_frame> ) -> Result<(), Errno>
§Safety
The provided frame must not be moved or destroyed before it is popped again.
The frame may only be assumed as initialized if this method returns Ok
.
sourcepub unsafe fn push_object(
&mut self,
frame: &mut MaybeUninit<spa_pod_frame>,
_type: u32
) -> Result<Id, Errno>
pub unsafe fn push_object( &mut self, frame: &mut MaybeUninit<spa_pod_frame>, _type: u32 ) -> Result<Id, Errno>
§Safety
The provided frame must not be moved or destroyed before it is popped again.
The frame may only be assumed as initialized if this method returns Ok
.