Struct ModelBuilder

Source
pub struct ModelBuilder { /* private fields */ }
Expand description

Builder used to easily create a Model

Implementations§

Source§

impl<'a> ModelBuilder

Source

pub fn vj<F>(self, name: &str, vj_initer: F) -> Self
where F: FnMut(VehicleJourneyBuilder<'_>),

Add a new VehicleJourney to the model

let model = transit_model_builder::ModelBuilder::default()
       .vj("toto", |vj_builder| {
           vj_builder
               .st("A", "10:00:00", "10:01:00")
               .st("B", "11:00:00", "11:01:00");
       })
       .vj("tata", |vj_builder| {
           vj_builder
               .st("C", "08:00:00", "08:01:00")
               .st("B", "09:00:00", "09:01:00");
       })
       .build();
Source

pub fn route<F>(self, id: &str, route_initer: F) -> Self
where F: FnMut(&mut Route),

Add a new Route to the model

let model = transit_model_builder::ModelBuilder::default()
     .route("l1", |r| {
            r.name = "ligne 1".to_owned();
        })
     .vj("toto", |vj| {
         vj.route("l1")
           .st("A", "10:00:00", "10:01:00")
           .st("B", "11:00:00", "11:01:00");
     })
     .build();
Source

pub fn calendar<F>(self, id: &str, calendar_initer: F) -> Self
where F: FnMut(&mut Calendar),

Add a new Calendar to the model


let model = transit_model_builder::ModelBuilder::default()
     .calendar("c1", |c| {
            c.dates.insert(Date::from_ymd(2019, 2, 6));
        })
     .vj("toto", |vj| {
         vj.calendar("c1")
           .st("A", "10:00:00", "10:01:00")
           .st("B", "11:00:00", "11:01:00");
     })
     .build();
Source

pub fn build(self) -> Model

Consume the builder to create a navitia model

Trait Implementations§

Source§

impl Default for ModelBuilder

Source§

fn default() -> ModelBuilder

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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Err>

Source§

impl<T> ErasedDestructor for T
where T: 'static,