Struct harfbuzz_rs::Blob[][src]

#[repr(C)]
pub struct Blob<'a> { /* fields omitted */ }
Expand description

A Blob manages raw data like e.g. file contents. It refers to a slice of bytes that can be either owned by the Blob or not.

It is used to provide access to memory for Face and Font. Typically it contains the raw font data (e.g. an entire font file or font tables). To enable shared usage of its data it uses a reference counting mechanism making the clone operation very cheap as no data is cloned.

Construction

A Blob implements Into for every type that satisfies the AsRef<[u8]> trait such as Vec<u8> and Box<[u8]> so owned blobs can be created easily from standard Rust objects.

You can also create Blobs that contain borrowed data using the constructors Blob::with_bytes and Blob::with_bytes_mut for immutable and mutable access respectively.

Implementations

Create a new Blob from the slice bytes. The blob will not own the slice’s data.

Create a new Blob from the mutable slice bytes. The blob will not own the slice’s data.

Create a new Blob from a type that owns a byte slice, effectively handing over ownership of its data to the blob.

Create a Blob from the contents of the file at path whose contents will be read into memory.

The result will be either a Blob that owns the file’s contents or an error that happened while trying to read the file.

This can be a performance problem if the file is very big. If this turns out to be a problem consider mmaping the file or splitting it into smaller chunks before creating a Blob.

Get a slice of the Blob’s bytes.

Creates an immutable Blob that contains part of the data of the parent Blob. The parent Blob will be immutable after this and the subBlob cannot outlive its parent.

Arguments

  • offset: Byte-offset of sub-blob within parent.
  • length: Length of the sub-blob.

Returns true if the blob is immutable.

HarfBuzz internally uses this value to make sure the blob is not mutated after being shared. In Rust this is not really necessary due to the borrow checker. This method is provided regardless for completeness.

Makes this blob immutable so the bytes it refers to will never change during its lifetime.

Try to get a mutable slice of the Blob’s bytes, possibly copying them.

This returns None if the blob is immutable or memory allocation failed.

Trait Implementations

Performs the conversion.

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Type of the raw harfbuzz object.

Returns the underlying harfbuzz object pointer. Read more

Increases the reference count of the HarfBuzz object. Read more

Decreases the reference count of the HarfBuzz object and destroys it if the reference count reaches zero. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.