Struct transit_model::model::Model

source ·
pub struct Model { /* private fields */ }
Expand description

The navitia transit model.

Implementations§

source§

impl Model

source

pub fn get_corresponding<T, U>(&self, from: &IdxSet<T>) -> IdxSet<U>where IdxSet<T>: GetCorresponding<U>,

Returns the set of U indices corresponding to the from set.

source

pub fn get_corresponding_from_idx<T, U>(&self, from: Idx<T>) -> IdxSet<U>where IdxSet<T>: GetCorresponding<U>,

Returns the set of U indices corresponding to the from index.

source§

impl Model

source

pub fn new(c: Collections) -> Result<Self>

Constructs a model from the given Collections. Fails in case of incoherence, as invalid external references.

Examples
let _: Model = Model::new(Collections::default())?;
let mut collections = Collections::default();
// This transfer is invalid as there is no stop points in collections
// but objects not referenced are removed from the model
collections.transfers = Collection::from(Transfer {
    from_stop_id: "invalid".into(),
    to_stop_id: "also_invalid".into(),
    min_transfer_time: None,
    real_min_transfer_time: None,
    equipment_id: None,
});
assert!(Model::new(collections).is_ok());
source

pub fn into_collections(self) -> Collections

Consumes collections,

Examples
let model: Model = Model::new(Collections::default())?;
let mut collections = model.into_collections();
 collections
   .feed_infos
   .insert("foo".to_string(), "bar".to_string());
let feeds: Vec<(_, _)> = collections.feed_infos.into_iter().collect();
assert_eq!(
   vec![("foo".to_string(), "bar".to_string())],
   feeds
);

Methods from Deref<Target = Collections>§

source

pub fn calculate_validity_period(&self) -> Result<(Date, Date)>

Calculate the validity period in the ‘Model’. The calculation is based on the minimum start date and the maximum end date of all the datasets. If no dataset is found, an error is returned.

Trait Implementations§

source§

impl Deref for Model

§

type Target = Collections

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<'de> Deserialize<'de> for Model

source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Serialize for Model

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Model

§

impl Send for Model

§

impl Sync for Model

§

impl Unpin for Model

§

impl UnwindSafe for Model

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<G1, G2> Within<G2> for G1where G2: Contains<G1>,

source§

fn is_within(&self, b: &G2) -> bool

source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,