Struct norad::LayerContents

source ·
pub struct LayerContents { /* private fields */ }
Expand description

The ordered list of Layer objects within a UFO.

A layer set always includes a default layer, and may also include additional layers.

Corresponds to layercontents.plist.

Implementations§

source§

impl LayerContents

source

pub fn len(&self) -> usize

Returns the number of layers in the set.

This is always non-zero.

source

pub fn get(&self, name: &str) -> Option<&Layer>

Returns a reference to a layer, by name.

source

pub fn get_mut(&mut self, name: &str) -> Option<&mut Layer>

Returns a mutable reference to a layer, by name.

source

pub fn default_layer(&self) -> &Layer

Returns a reference to the default layer.

source

pub fn default_layer_mut(&mut self) -> &mut Layer

Returns a mutable reference to the default layer.

source

pub fn iter(&self) -> impl Iterator<Item = &Layer>

Returns an iterator over all layers.

source

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

Returns a mutable iterator over all layers.

source

pub fn names(&self) -> impl Iterator<Item = &Name>

Returns an iterator over the names of all layers.

source

pub fn new_layer(&mut self, name: &str) -> Result<&mut Layer, NamingError>

Returns a new layer with the given name.

source

pub fn get_or_create_layer( &mut self, name: &str ) -> Result<&mut Layer, NamingError>

Returns a mutable reference to a layer, by name, creating the layer if it doesn’t exist

source

pub fn remove(&mut self, name: &str) -> Option<Layer>

Remove a layer.

The default layer cannot be removed.

source

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

Rename a layer.

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

Returns an error if overwrite is false but a layer with the new name exists, if no layer with the old name exists, if the new name is not a valid Name or when anything but the default layer should be renamed to “public.default”.

source

pub fn retain<F>(&mut self, predicate: F)
where F: FnMut(&Layer) -> bool,

Retains the default layer, and any layers allowed by the predicate.

In other words, remove all layers l for which predicate(&l) returns false. This method operates in place, visiting each layer exactly once in the original order, and preserves the order of the retained layers.

For more information, see Vec::retain.

source

pub fn remove_empty_layers(&mut self)

Removes any layers that contain no glyphs

Trait Implementations§

source§

impl Clone for LayerContents

source§

fn clone(&self) -> LayerContents

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 LayerContents

source§

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

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

impl Default for LayerContents

source§

fn default() -> Self

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

impl PartialEq for LayerContents

source§

fn eq(&self, other: &Self) -> 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.

Auto Trait Implementations§

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.