Struct Schemas

Source
pub struct Schemas;
Expand description

Starting point for defining the dimensions of a dataset.

use flat::Schema;

let my_schema = Schemas::two("dimension_0", "dimension_1");

Implementations§

Source§

impl Schemas

Source

pub fn one<T>(dimension_0: impl Into<String>) -> Schema1<T>

Define a 1-dimensional schema. The names of the dimensions are specified in order.

§Example
use flat::*;

// The inventory of animals in a zoo.
// This dataset has 2 bears, and 1 tiger.
let schema = Schemas::one("Animal");
let dataset = DatasetBuilder::new(schema)
    //   (Animal,)
    .add(("Bear",))
    .add(("Bear",))
    .add(("Tiger",))
    .build();
Source

pub fn two<T, U>( dimension_0: impl Into<String>, dimension_1: impl Into<String>, ) -> Schema2<T, U>

Define a 2-dimensional schema. The names of the dimensions are specified in order.

§Example
use flat::*;

// A dataset describing the zoo animal heights.
// This dataset has a bear which measures height "10", and another which measures height "11".
// There is also a tiger which measures height "5".
let schema = Schemas::two("Animal", "Height");
let dataset = DatasetBuilder::new(schema)
    //   (Animal, Height)
    .add(("Bear", 10))
    .add(("Bear", 11))
    .add(("Tiger", 5))
    .build();
Source

pub fn three<T, U, V>( dimension_0: impl Into<String>, dimension_1: impl Into<String>, dimension_2: impl Into<String>, ) -> Schema3<T, U, V>

Define a 3-dimensional schema. The names of the dimensions are specified in order.

§Example
use flat::*;

// A dataset with zoo animal heights and their enclosures.
// This dataset has a bear which measures height "10", and another which measures height "11".
// There is also a tiger which measures height "5".
// The bears live in Pen01, while the tiger lives in Pen02.
let schema = Schemas::three("Animal", "Height", "Enclosure");
let dataset = DatasetBuilder::new(schema)
    //   (Animal, Height, Enclosure)
    .add(("Bear", 10, "Pen01"))
    .add(("Bear", 11, "Pen01"))
    .add(("Tiger", 5, "Pen02"))
    .build();
Source

pub fn four<T, U, V, W>( dimension_0: impl Into<String>, dimension_1: impl Into<String>, dimension_2: impl Into<String>, dimension_3: impl Into<String>, ) -> Schema4<T, U, V, W>

Define a 4-dimensional schema. The names of the dimensions are specified in order.

§Example
use flat::*;

// A dataset with zoo animal heights and their enclosures.
// This dataset has a bear which measures height "10", and another which measures height "11".
// There is also a tiger which measures height "5".
// The bears live in Pen01 (North East quadrant), while the tiger lives in Pen02 (South West quadrant).
let schema = Schemas::four("Animal", "Height", "Enclosure", "Quadrant");
let dataset = DatasetBuilder::new(schema)
    //   (Animal, Height, Enclosure, Quadrant)
    .add(("Bear", 10, "Pen01", "NorthEast"))
    .add(("Bear", 11, "Pen01", "NorthEast"))
    .add(("Tiger", 5, "Pen02", "SouthWest"))
    .build();

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

Source§

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.