[][src]Struct temporal_networks::interval::Interval

pub struct Interval(pub f64, pub f64);

An interval represents a context-agnostic inclusive [lower, upper] time range. While Interval may be accessible from JS, the Rust implementation includes additional operator overloads for simplified arithmetic.

JS-specific

Examples

Interval arithmetic in Rust.

use temporal_networks::interval::Interval;

let interval1 = Interval::new(0., 10.);
let interval2 = Interval::new(5., 16.);

let summed_interval = Interval::new(5., 26.);
assert_eq!(interval1 + interval2, summed_interval);

let diff_interval = Interval::new(-5., 16.);
assert_eq!(interval2 - interval1, diff_interval);

let unioned_interval = Interval::new(5., 10.);
assert_eq!(interval1 & interval2, unioned_interval);

Methods

impl Interval[src]

pub fn new(lower: f64, upper: f64) -> Interval[src]

Create a new Interval

pub fn from_vec(other: Vec<f64>) -> Interval[src]

Get an interval from a vector

pub fn to_json(&self) -> JsValue[src]

Convert the interval to JSON [lower, upper]

pub fn lower(&self) -> f64[src]

The lower bound of the range

pub fn upper(&self) -> f64[src]

The upper bound of the range

pub fn contains(&self, v: f64) -> bool[src]

Whether or not a point in time falls within a range

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

A check that ensures the lower bound is less than the upper bound

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

Whether or not the interval has converged to a time

pub fn union(&self, other: &Interval) -> Interval[src]

Union these intervals

Trait Implementations

impl Add<Interval> for Interval[src]

type Output = Interval

The resulting type after applying the + operator.

fn add(self, other: Interval) -> Interval[src]

create a new interval from the addition of two other intervals

impl AddAssign<Interval> for Interval[src]

impl BitAnd<Interval> for Interval[src]

type Output = Interval

The resulting type after applying the & operator.

impl BitAndAssign<Interval> for Interval[src]

impl Clone for Interval[src]

impl Copy for Interval[src]

impl Debug for Interval[src]

impl Default for Interval[src]

impl<'de> Deserialize<'de> for Interval[src]

impl Display for Interval[src]

impl From<Interval> for JsValue[src]

impl FromWasmAbi for Interval[src]

type Abi = u32

The wasm ABI type that this converts from when coming back out from the ABI boundary. Read more

impl IntoWasmAbi for Interval[src]

type Abi = u32

The wasm ABI type that this converts into when crossing the ABI boundary. Read more

impl Neg for Interval[src]

type Output = Interval

The resulting type after applying the - operator.

impl OptionFromWasmAbi for Interval[src]

impl OptionIntoWasmAbi for Interval[src]

impl PartialEq<Interval> for Interval[src]

impl RefFromWasmAbi for Interval[src]

type Abi = u32

The wasm ABI type references to Self are recovered from.

type Anchor = Ref<'static, Interval>

The type that holds the reference to Self for the duration of the invocation of the function that has an &Self parameter. This is required to ensure that the lifetimes don't persist beyond one function call, and so that they remain anonymous. Read more

impl RefMutFromWasmAbi for Interval[src]

type Abi = u32

Same as RefFromWasmAbi::Abi

type Anchor = RefMut<'static, Interval>

Same as RefFromWasmAbi::Anchor

impl Serialize for Interval[src]

impl StructuralPartialEq for Interval[src]

impl Sub<Interval> for Interval[src]

type Output = Interval

The resulting type after applying the - operator.

impl SubAssign<Interval> for Interval[src]

impl WasmDescribe for Interval[src]

Auto Trait Implementations

impl RefUnwindSafe for Interval

impl Send for Interval

impl Sync for Interval

impl Unpin for Interval

impl UnwindSafe for Interval

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<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

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

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

impl<T> ReturnWasmAbi for T where
    T: IntoWasmAbi
[src]

type Abi = <T as IntoWasmAbi>::Abi

Same as IntoWasmAbi::Abi

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

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

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.