Struct norad::Layer

source ·
pub struct Layer {
    pub color: Option<Color>,
    pub lib: Plist,
    /* private fields */
}
Expand description

A UFO layer, corresponding to a ‘glyphs’ sub-directory.

Conceptually, a layer is just a collection of glyphs.

Fields§

§color: Option<Color>

An optional color, specified in the layer’s layerinfo.plist.

§lib: Plist

Optional lib data for this layer.

An empty lib is not serialized.

Implementations§

source§

impl Layer

source

pub fn len(&self) -> usize

Returns the number of Glyphs in the layer.

source

pub fn is_empty(&self) -> bool

Returns true if this layer contains no glyphs.

source

pub fn is_default(&self) -> bool

Returns true if this layer is the default layer.

The default layer can have any name, but always uses the “glyphs” directory.

source

pub fn name(&self) -> &Name

Returns the name of the layer.

This can only be mutated through the LayerContents.

source

pub fn path(&self) -> &Path

Returns the directory path of this layer.

This cannot be mutated; it is either provided when the layer is loaded, or we will create it for you. Maybe this is bad? We can talk about it, if you like.

source

pub fn entry(&mut self, glyph: Name) -> Entry<'_, Name, Glyph>

Gets the given key’s corresponding entry in the map for in-place manipulation.

source

pub fn get_glyph(&self, glyph: &str) -> Option<&Glyph>

Returns a reference to the glyph with the given name, if it exists.

source

pub fn get_glyph_mut(&mut self, glyph: &str) -> Option<&mut Glyph>

Returns a mutable reference to the glyph with the given name, if it exists.

source

pub fn contains_glyph(&self, name: &str) -> bool

Returns true if this layer contains a glyph with this name.

source

pub fn insert_glyph(&mut self, glyph: impl Into<Glyph>)

Adds or updates the given glyph.

If the glyph does not previously exist, the filename is calculated from the glyph’s name.

source

pub fn clear(&mut self)

Remove all glyphs in the layer. Leave color and the lib untouched.

source

pub fn remove_glyph(&mut self, name: &str) -> Option<Glyph>

Remove the named glyph from this layer and return it, if it exists.

source

pub fn rename_glyph( &mut self, old: &str, new: &str, overwrite: bool ) -> Result<(), NamingError>

Rename a glyph.

If overwrite is true, and a glyph with the new name exists, it will be replaced.

Returns an error if overwrite is false but a glyph with the new name exists, or if no glyph with the old name exists, or if the new name is not a valid Name.

source

pub fn iter(&self) -> impl Iterator<Item = &Glyph> + '_

Returns an iterator over the glyphs in this layer.

source

pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut Glyph>

Returns an iterator over the glyphs in this layer, mutably.

source

pub fn retain(&mut self, f: impl FnMut(&Name, &mut Glyph) -> bool)

Retains only the elements specified by the predicate.

In other words, remove all pairs (k, v) for which f(&k, &mut v) returns false. The elements are visited in unsorted (and unspecified) order.

source

pub fn get_path(&self, name: &str) -> Option<&Path>

Returns the path to the .glif file of a given glyph name.

The returned path is relative to the path of the current layer.

Trait Implementations§

source§

impl Clone for Layer

source§

fn clone(&self) -> Layer

Returns a copy 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 Debug for Layer

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for Layer

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl PartialEq for Layer

source§

fn eq(&self, other: &Layer) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for Layer

Auto Trait Implementations§

§

impl Freeze for Layer

§

impl RefUnwindSafe for Layer

§

impl Send for Layer

§

impl Sync for Layer

§

impl Unpin for Layer

§

impl UnwindSafe for Layer

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> 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,

§

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>,

§

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>,

§

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.