[][src]Struct genie::Palette

pub struct Palette { /* fields omitted */ }

A Palette.

Implementations

impl Palette[src]

pub fn new() -> Palette[src]

Create an empty palette.

pub fn read_from(input: impl Read) -> Result<Palette, ReadPaletteError>[src]

Read a palette from an input stream.

pub fn write_to(&self, output: impl Write) -> Result<(), Error>[src]

Write a palette to an output stream.

pub fn into_inner(self) -> Vec<RGB<u8>>[src]

Return the colours in a Vec so it can be manipulated.

It can later be wrapped back into a Palette instance using Palette::from(vec).

pub fn colors(&self) -> &[RGB<u8>][src]

Return the colours as a slice.

pub fn colors_mut(&mut self) -> &mut Vec<RGB<u8>>[src]

Return the colours as a mutable vector.

pub fn len(&self) -> usize[src]

Returns the number of colours in this palette.

pub fn is_empty(&self) -> bool[src]

Returns true if this palette contains 0 colours.

pub fn add(&mut self, color: RGB<u8>)[src]

Add a colour at the end of the palette.

pub fn to_bytes(&self) -> Vec<u8>[src]

Serialize the palette to a byte vector.

Trait Implementations

impl Clone for Palette[src]

impl Debug for Palette[src]

impl Default for Palette[src]

fn default() -> Palette[src]

Create a palette with 256 colours, all black.

impl Eq for Palette[src]

impl From<Vec<RGB<u8>>> for Palette[src]

fn from(colors: Vec<RGB<u8>>) -> Palette[src]

Create a palette from a vector of colours.

impl FromStr for Palette[src]

type Err = ReadPaletteError

The associated error which can be returned from parsing.

fn from_str(input: &str) -> Result<Palette, <Palette as FromStr>::Err>[src]

Parse a palette from a UTF-8 string.

impl Index<PaletteIndex> for Palette[src]

type Output = RGB<u8>

The returned type after indexing.

fn index(
    &self,
    index: PaletteIndex
) -> &<Palette as Index<PaletteIndex>>::Output
[src]

Get the colour at the given index.

impl IndexMut<PaletteIndex> for Palette[src]

fn index_mut(
    &mut self,
    index: PaletteIndex
) -> &mut <Palette as Index<PaletteIndex>>::Output
[src]

Get the colour at the given index.

impl IntoIterator for Palette[src]

type Item = RGB<u8>

The type of the elements being iterated over.

type IntoIter = IntoIter<RGB<u8>>

Which kind of iterator are we turning this into?

impl<'a> IntoIterator for &'a Palette[src]

type Item = &'a RGB<u8>

The type of the elements being iterated over.

type IntoIter = Iter<'a, RGB<u8>>

Which kind of iterator are we turning this into?

impl PartialEq<Palette> for Palette[src]

impl StructuralEq for Palette[src]

impl StructuralPartialEq for Palette[src]

impl ToString for Palette[src]

Auto Trait Implementations

impl RefUnwindSafe for Palette

impl Send for Palette

impl Sync for Palette

impl Unpin for Palette

impl UnwindSafe for Palette

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

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

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

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

type Owned = T

The resulting type after obtaining ownership.

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.