[][src]Enum rusttype::SharedBytes

pub enum SharedBytes<'a> {
    ByRef(&'a [u8]),
    ByArc(Arc<[u8]>),
}

SharedBytes handles the lifetime of font data used in RustType. The data is either a shared reference to externally owned data, or managed by reference counting. SharedBytes can be conveniently used with From and Into, and dereferences to the contained bytes.

Lifetime

The lifetime reflects the font data lifetime. SharedBytes<'static> covers most cases ie both dynamically loaded owned data and for referenced compile time font data.

Variants

Trait Implementations

impl<'a> From<&'a [u8]> for SharedBytes<'a>
[src]

let bytes: &[u8] = &[0u8, 1, 2, 3];
let shared: SharedBytes = bytes.into();
assert_eq!(&*shared, bytes);

Performs the conversion.

impl From<Arc<[u8]>> for SharedBytes<'static>
[src]

let bytes: Arc<[u8]> = vec![0u8, 1, 2, 3].into();
let shared: SharedBytes = Arc::clone(&bytes).into();
assert_eq!(&*shared, &*bytes);

Performs the conversion.

impl From<Box<[u8]>> for SharedBytes<'static>
[src]

let bytes: Box<[u8]> = vec![0u8, 1, 2, 3].into();
let shared: SharedBytes = bytes.into();
assert_eq!(&*shared, &[0u8, 1, 2, 3]);

Performs the conversion.

impl From<Vec<u8>> for SharedBytes<'static>
[src]

let bytes = vec![0u8, 1, 2, 3];
let shared: SharedBytes = bytes.into();
assert_eq!(&*shared, &[0u8, 1, 2, 3]);

Performs the conversion.

impl<'a, T: AsRef<[u8]>> From<&'a T> for SharedBytes<'a>
[src]

let bytes = vec![0u8, 1, 2, 3];
let shared: SharedBytes = (&bytes).into();
assert_eq!(&*shared, &bytes as &[u8]);

Performs the conversion.

impl<'a> Clone for SharedBytes<'a>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<'a> Deref for SharedBytes<'a>
[src]

The resulting type after dereferencing.

Dereferences the value.

impl<'a> Debug for SharedBytes<'a>
[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl<'a> Send for SharedBytes<'a>

impl<'a> Sync for SharedBytes<'a>

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

impl<T> From for T
[src]

Performs the conversion.

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> Borrow for T where
    T: ?Sized
[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut for T where
    T: ?Sized
[src]

Mutably borrows from an owned value. Read more

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

🔬 This is a nightly-only experimental API. (get_type_id)

this method will likely be replaced by an associated static

Gets the TypeId of self. Read more