Struct napchart::Napchart[][src]

pub struct Napchart {
    pub shape: ChartShape,
    pub color_tags: HashMap<ChartColor, String>,
    // some fields omitted
}

A napchart, as seen on https://napchart.com/

Fields

shape: ChartShape

The default shape of the napchart on napchart.com

color_tags: HashMap<ChartColor, String>

String tags associated with element colors. These are displayed in the inner area of a napchart, along with the accumulated amount of time each color takes up.

Implementations

impl Napchart[src]

pub fn add_lane(&mut self) -> &mut ChartLane[src]

Append a new blank lane to the chart and return a mutable reference to it.

let mut chart = Napchart::default();
let mut lane = chart.add_lane();
assert!(lane.is_empty());
assert_eq!(chart.lanes_len(), 1);

pub fn get_lane(&self, i: usize) -> Option<&ChartLane>[src]

Get a reference to the given lane, or None if out of bounds.

let mut chart = Napchart::default();
chart.add_lane();
assert!(chart.get_lane(0).is_some());
assert!(chart.get_lane(1).is_none());

pub fn get_lane_mut(&mut self, i: usize) -> Option<&mut ChartLane>[src]

Get a mutable reference to the given lane, or None if out of bounds.

let mut chart = Napchart::default();
chart.add_lane();
assert!(chart.get_lane_mut(0).is_some());
assert!(chart.get_lane_mut(1).is_none());

pub fn remove_lane(&mut self, i: usize) -> Option<ChartLane>[src]

Remove the given lane from the chart and return it, or None if out of bounds.

let mut chart = Napchart::default();
chart.add_lane();
let lane = chart.remove_lane(0);
assert!(lane.is_some());
assert_eq!(chart.lanes_len(), 0);

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

Get the total number of lanes in the chart.

let mut chart = Napchart::default();
assert_eq!(chart.lanes_len(), 0);
chart.add_lane();
assert_eq!(chart.lanes_len(), 1);
chart.add_lane();
assert_eq!(chart.lanes_len(), 2);
chart.remove_lane(1);
chart.remove_lane(0);
assert_eq!(chart.lanes_len(), 0);

pub fn upload(&self) -> UploadBuilder<'_>[src]

Create an UploadBuilder with a reference to this chart.

let client = BlockingClient::default();
let chart = Napchart::default();
let upload: napchart::api::UploadBuilder = chart.upload().title("My Cool Chart");
assert!(client.create_snapshot(upload).is_ok());

impl Napchart[src]

Builder functions to create new napcharts.

let chart = Napchart::default()
                .lanes(3)
                .shape(ChartShape::Wide);
assert_eq!(chart.lanes_len(), 3);
assert_eq!(chart.shape, ChartShape::Wide);

pub fn shape(self, shape: ChartShape) -> Self[src]

Return Napchart with shape set.

let chart = Napchart::default();
assert_eq!(chart.shape, ChartShape::Circle);

let wide_chart = Napchart::default().shape(ChartShape::Wide);
assert_eq!(wide_chart.shape, ChartShape::Wide);

pub fn lanes(self, count: usize) -> Self[src]

Return Napchart with a given number of empty lanes.

let chart = Napchart::default();
assert_eq!(chart.lanes_len(), 0);

let chart2 = Napchart::default().lanes(3);
assert_eq!(chart2.lanes_len(), 3);

Trait Implementations

impl Clone for Napchart[src]

impl Debug for Napchart[src]

impl Default for Napchart[src]

impl Eq for Napchart[src]

impl PartialEq<Napchart> for Napchart[src]

impl StructuralEq for Napchart[src]

impl StructuralPartialEq for Napchart[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>,