Struct napchart::ChartLane[][src]

pub struct ChartLane {
    pub locked: bool,
    // some fields omitted
}

A single lane of a napchart

Fields

locked: bool

Whether the lane is locked on napchart.com. Has no effect in rust.

Implementations

impl ChartLane[src]

pub fn clear(&mut self)[src]

Clear all elements from the lane.

let mut chart = Napchart::default();
let mut lane = chart.add_lane();
lane.add_element(0, 60).unwrap();
lane.add_element(60, 120).unwrap();
lane.add_element(120, 180).unwrap();
assert!(!lane.is_empty());
lane.clear();
assert!(lane.is_empty());

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

True if the lane has no elements.

let mut chart = Napchart::default();
let mut lane = chart.add_lane();
assert!(lane.is_empty());
lane.add_element(0, 60).unwrap();
assert!(!lane.is_empty());

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

The number of elements in the lane.

let mut chart = Napchart::default();
let mut lane = chart.add_lane();
assert_eq!(lane.elems_len(), 0);
lane.add_element(0, 60).unwrap();
lane.add_element(60, 120).unwrap();
lane.add_element(120, 180).unwrap();
assert_eq!(lane.elems_len(), 3);

pub fn add_element(
    &mut self,
    start: u16,
    end: u16
) -> Result<&mut ChartElement, ErrorKind>
[src]

Add a new element to the lane. Start and end must both be between [0 and 1440). Error if the new element would overlap with the existing elements.

let mut chart = Napchart::default();
let mut lane = chart.add_lane();
assert!(lane.add_element(0, 30).is_ok());
assert!(lane.add_element(15, 45).is_err());
assert!(lane.add_element(30, 60).is_ok());
assert_eq!(lane.elems_len(), 2);

pub fn elems_iter(&self) -> Iter<'_, ChartElement>[src]

Get an iterator over the elements in the lane.

let mut chart = Napchart::default();
let mut lane = chart.add_lane();
lane.add_element(0, 60).unwrap();
lane.add_element(60, 120).unwrap();
lane.add_element(120, 180).unwrap();
let mut iter = lane.elems_iter();
assert_eq!(iter.next().unwrap().get_position(), (0, 60));
assert_eq!(iter.next().unwrap().get_position(), (60, 120));
assert_eq!(iter.next().unwrap().get_position(), (120, 180));

Trait Implementations

impl Clone for ChartLane[src]

impl Debug for ChartLane[src]

impl Default for ChartLane[src]

impl Eq for ChartLane[src]

impl PartialEq<ChartLane> for ChartLane[src]

impl StructuralEq for ChartLane[src]

impl StructuralPartialEq for ChartLane[src]

Auto Trait Implementations

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<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

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

impl<T> Instrument for T[src]

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

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

type Owned = T

The resulting type after obtaining ownership.

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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,