pub struct Cursor<'a> {
pos: usize,
data: FontData<'a>,
}
Expand description
A cursor for validating bytes during parsing.
This type improves the ergonomics of validation blah blah
§Note
call finish
when you’re done to ensure you’re in bounds
Fields§
§pos: usize
§data: FontData<'a>
Implementations§
Source§impl<'a> Cursor<'a>
impl<'a> Cursor<'a>
pub(crate) fn advance<T: Scalar>(&mut self)
pub(crate) fn advance_by(&mut self, n_bytes: usize)
Sourcepub(crate) fn read_u32_var(&mut self) -> Result<u32, ReadError>
pub(crate) fn read_u32_var(&mut self) -> Result<u32, ReadError>
Read a variable length u32 and advance the cursor
Sourcepub(crate) fn read<T: Scalar>(&mut self) -> Result<T, ReadError>
pub(crate) fn read<T: Scalar>(&mut self) -> Result<T, ReadError>
Read a scalar and advance the cursor.
Sourcepub(crate) fn read_be<T: Scalar>(&mut self) -> Result<BigEndian<T>, ReadError>
pub(crate) fn read_be<T: Scalar>(&mut self) -> Result<BigEndian<T>, ReadError>
Read a big-endian value and advance the cursor.
pub(crate) fn read_with_args<T>(
&mut self,
args: &T::Args,
) -> Result<T, ReadError>where
T: FontReadWithArgs<'a> + ComputeSize,
pub(crate) fn read_computed_array<T>(
&mut self,
len: usize,
args: &T::Args,
) -> Result<ComputedArray<'a, T>, ReadError>where
T: FontReadWithArgs<'a> + ComputeSize,
pub(crate) fn read_array<T: AnyBitPattern + FixedSize>( &mut self, n_elem: usize, ) -> Result<&'a [T], ReadError>
Sourcepub(crate) fn position(&self) -> Result<usize, ReadError>
pub(crate) fn position(&self) -> Result<usize, ReadError>
return the current position, or an error if we are out of bounds
pub(crate) fn remaining_bytes(&self) -> usize
pub(crate) fn remaining(self) -> Option<FontData<'a>>
pub fn is_empty(&self) -> bool
pub(crate) fn finish<T>(self, shape: T) -> Result<TableRef<'a, T>, ReadError>
Trait Implementations§
impl<'a> Copy for Cursor<'a>
Auto Trait Implementations§
impl<'a> Freeze for Cursor<'a>
impl<'a> RefUnwindSafe for Cursor<'a>
impl<'a> Send for Cursor<'a>
impl<'a> Sync for Cursor<'a>
impl<'a> Unpin for Cursor<'a>
impl<'a> UnwindSafe for Cursor<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more