pub struct Ptr<'buf, S> {
pub offset: isize,
pub buf: &'buf [u8],
/* private fields */
}
Expand description
A reference to a fontconfig struct that’s been serialized in a buffer.
Fields§
§offset: isize
We point at this offset
, relative to the buffer.
buf: &'buf [u8]
The buffer that we point into.
Implementations§
Source§impl<'buf, S: AnyBitPattern> Ptr<'buf, S>
impl<'buf, S: AnyBitPattern> Ptr<'buf, S>
Sourcepub fn relative_offset<Off: IntoOffset>(
&self,
offset: Off,
) -> Result<Ptr<'buf, Off::Item>, Error>
pub fn relative_offset<Off: IntoOffset>( &self, offset: Off, ) -> Result<Ptr<'buf, Off::Item>, Error>
Turn offset
into a pointer, assuming that it’s an offset relative to this pointer.
In order to be certain about which offsets are relative to what, you’ll need to check
the fontconfig source. But generally, offsets stored in a struct are relative to the
base address of that struct. So for example, to access the dir
field in
Cache
you could call cache.relative_offset(cache.deref()?.dir)?
.
This will give you a Ptr<u8>
pointing to the start of the directory name.
Trait Implementations§
Auto Trait Implementations§
impl<'buf, S> Freeze for Ptr<'buf, S>
impl<'buf, S> RefUnwindSafe for Ptr<'buf, S>where
S: RefUnwindSafe,
impl<'buf, S> Send for Ptr<'buf, S>where
S: Send,
impl<'buf, S> Sync for Ptr<'buf, S>where
S: Sync,
impl<'buf, S> Unpin for Ptr<'buf, S>where
S: Unpin,
impl<'buf, S> UnwindSafe for Ptr<'buf, S>where
S: UnwindSafe,
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