[][src]Struct harfbuzz_rs::Tag

#[repr(transparent)]
pub struct Tag(pub hb_tag_t);

A type to represent 4-byte SFNT tags.

Tables, features, etc. in OpenType and many other font formats use SFNT tags as identifiers. These are 4-bytes long and usually each byte represents an ASCII value. Tag provides methods to create such identifiers from individual chars or a str slice and to get the string representation of a Tag.

Methods

impl Tag[src]

pub const fn new(a: char, b: char, c: char, d: char) -> Self[src]

Create a Tag from its four-char textual representation.

All the arguments must be ASCII values.

Examples

use harfbuzz_rs::Tag;
let cmap_tag = Tag::new('c', 'm', 'a', 'p');
assert_eq!(cmap_tag.to_string(), "cmap")

pub const fn to_bytes(self) -> [u8; 4][src]

Returns tag as 4-element byte array.

Examples

let tag = Tag::new('a', 'b', 'c', 'd');
assert_eq!(&tag.to_bytes(), b"abcd");

Trait Implementations

impl Eq for Tag[src]

impl Clone for Tag[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Copy for Tag[src]

impl PartialEq<Tag> for Tag[src]

impl Hash for Tag[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl Debug for Tag[src]

impl Display for Tag[src]

impl FromStr for Tag[src]

type Err = TagFromStrErr

The associated error which can be returned from parsing.

fn from_str(s: &str) -> Result<Tag, TagFromStrErr>[src]

Parses a Tag from a &str that contains four or less ASCII characters. When the string's length is smaller than 4 it is extended with ' ' (Space) characters. The remaining bytes of strings longer than 4 bytes are ignored.

Examples

use harfbuzz_rs::Tag;
use std::str::FromStr;
let tag1 = Tag::from_str("ABCD").unwrap();
let tag2 = Tag::new('A', 'B', 'C', 'D');
assert_eq!(tag1, tag2);

Auto Trait Implementations

impl Send for Tag

impl Sync for Tag

Blanket Implementations

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

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

type Owned = T

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> From for T[src]

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

type Error = !

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

The type returned in the event of a conversion error.

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

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

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

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

The type returned in the event of a conversion error.

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

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