[−][src]Struct alass_core::TimeSpan
Represents a time span from "start" (included) to "end" (excluded).
The constructors will ensure "start <= end", this condition will hold at any given time.
Fields
start: TimePoint
The first time point of the time span (inclusive)
end: TimePoint
The last time point of the time span (excluded)
Methods
impl TimeSpan
[src]
pub fn new(start: TimePoint, end: TimePoint) -> TimeSpan
[src]
Create a new TimeSpan with start
and end
.
Examples
use alass_core::{TimeSpan, TimePoint}; let t0 = TimePoint::from(0); let t10 = TimePoint::from(10); let ts = TimeSpan::new(t0, t10);
Panics
This function asserts that start
is less or equal end
.
use alass_core::{TimeSpan, TimePoint}; let t0 = TimePoint::from(0); let t10 = TimePoint::from(10); // this will case a panic let ts = TimeSpan::new(t10, t0);
pub fn new_safe(start: TimePoint, end: TimePoint) -> TimeSpan
[src]
Create a new TimeSpan with start
and end
. This function will not
panic on end < start
, but
swap the values before calling TimeSpan::new()
.
Examples
use alass_core::{TimeSpan, TimePoint}; let t0 = TimePoint::from(0); let t10 = TimePoint::from(10); let ts = TimeSpan::new_safe(t10, t0); assert!(ts.start() == t0 && ts.end() == t10);
pub fn new_copy_with_end(self, new_end: TimePoint) -> TimeSpan
[src]
pub fn len(self) -> TimeDelta
[src]
Returns the length of the TimeSpan
.
len()
is zero, if and only if start
is end
.
pub fn is_empty(self) -> bool
[src]
Returns true if start == end
.
pub fn start(self) -> TimePoint
[src]
Returns the start point of the TimeSpan
.
pub fn end(self) -> TimePoint
[src]
Returns the end point of the TimeSpan
.
pub fn half(self) -> TimePoint
[src]
Returns one (of the possibly two) points in the center of the TimeSpan
.
pub fn contains(self, other: TimeSpan) -> bool
[src]
pub fn fast_distance_to(self, other: TimeSpan) -> TimeDelta
[src]
Returns the smallest difference between two TimeSpan
s.
use alass_core::{TimeSpan, TimePoint, TimeDelta}; let p = TimePoint::from(0); let d = TimeDelta::one(); let ts1 = TimeSpan::new(p, p + 10 * d); let ts4 = TimeSpan::new(p + 20 * d, p + 100 * d); assert!(TimeSpan::fast_distance_to(ts1, ts1) == 0 * d); assert!(TimeSpan::fast_distance_to(ts1, ts4) == 10 * d); assert!(TimeSpan::fast_distance_to(ts4, ts1) == 10 * d); assert!(TimeSpan::fast_distance_to(ts4, ts4) == 0 * d);
pub fn get_overlapping_length(self, other: TimeSpan) -> TimeDelta
[src]
Returns the smallest difference between two TimeSpan
s.
pub fn scaled(self, scaling_factor: f64) -> TimeSpan
[src]
Scale start and end time point to zero by scaling_factor
.
pub fn cmp_start(self, other: TimeSpan) -> Ordering
[src]
Compares two TimeSpan
s by their start timepoint.
pub fn cmp_end(self, other: TimeSpan) -> Ordering
[src]
Compares two TimeSpan
s by their end timepoint.
Trait Implementations
impl Clone for TimeSpan
[src]
impl Copy for TimeSpan
[src]
impl Eq for TimeSpan
[src]
impl PartialEq<TimeSpan> for TimeSpan
[src]
impl Debug for TimeSpan
[src]
impl Add<TimeDelta> for TimeSpan
[src]
type Output = TimeSpan
The resulting type after applying the +
operator.
fn add(self, rhs: TimeDelta) -> TimeSpan
[src]
impl Hash for TimeSpan
[src]
Auto Trait Implementations
impl Send for TimeSpan
impl Sync for TimeSpan
impl Unpin for TimeSpan
impl UnwindSafe for TimeSpan
impl RefUnwindSafe for TimeSpan
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,