Struct Ptr

Source
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> Ptr<'buf, u8>

Source

pub fn str(&self) -> Result<&'buf [u8], Error>

Assuming that this Ptr<u8> is pointing to the beginning of a null-terminated string, return that string.

Source§

impl<'buf, S: AnyBitPattern> Ptr<'buf, S>

Source

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.

Source

pub fn deref(&self) -> Result<S, Error>

“Dereference” this pointer, returning a plain struct.

Source

pub fn array(&self, count: c_int) -> Result<Array<'buf, S>, Error>

Treating this pointer as a reference to the start of an array of length count, return an iterator over that array.

Source§

impl<'buf> Ptr<'buf, ValueData>

Source

pub fn to_value(&self) -> Result<Value<'buf>, Error>

Converts the raw C representation to an enum.

Trait Implementations§

Source§

impl<'buf, S: Clone> Clone for Ptr<'buf, S>

Source§

fn clone(&self) -> Ptr<'buf, S>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'buf, S> Debug for Ptr<'buf, S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.