pub struct Range { /* private fields */ }Implementations§
source§impl Range
impl Range
pub fn from(begin: EventId) -> Self
sourcepub fn begin(&self) -> &EventId
pub fn begin(&self) -> &EventId
Examples found in repository?
src/range.rs (line 12)
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.begin().timestamp().cmp(other.begin().timestamp())
}
}
impl PartialOrd for Range {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.begin().timestamp().cmp(other.begin().timestamp()))
}
}
impl Range {
#[allow(dead_code)]
pub fn from(begin: EventId) -> Self {
Self {
events: vec![begin]
}
}
pub fn begin(&self) -> &EventId {
&self.events[0]
}
pub fn end(&self) -> &EventId {
&self.events[self.events.len()-1]
}
#[allow(dead_code)]
pub fn add_event(&mut self, end: EventId) {
assert!(self.can_contain(&end));
self.events.push(end);
}
#[allow(dead_code)]
pub fn can_contain(&self, id: &EventId) -> bool {
id.follows(self.end())
}
#[allow(dead_code)]
pub fn len(&self) -> usize {
self.events.len()
}
#[allow(dead_code)]
pub fn is_empty(&self) -> bool {
self.len() == 0
}
#[allow(dead_code)]
pub fn events(&self) -> std::slice::Iter<'_, EventId> {
self.events.iter()
}
}
impl Display for Range {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{} - {} ({} - {})",
self.begin().timestamp().format("%FT%T"),
self.end().timestamp().format("%FT%T"),
self.begin().event_record_id(),
self.end().event_record_id())
}sourcepub fn end(&self) -> &EventId
pub fn end(&self) -> &EventId
Examples found in repository?
src/range.rs (line 46)
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
pub fn can_contain(&self, id: &EventId) -> bool {
id.follows(self.end())
}
#[allow(dead_code)]
pub fn len(&self) -> usize {
self.events.len()
}
#[allow(dead_code)]
pub fn is_empty(&self) -> bool {
self.len() == 0
}
#[allow(dead_code)]
pub fn events(&self) -> std::slice::Iter<'_, EventId> {
self.events.iter()
}
}
impl Display for Range {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{} - {} ({} - {})",
self.begin().timestamp().format("%FT%T"),
self.end().timestamp().format("%FT%T"),
self.begin().event_record_id(),
self.end().event_record_id())
}pub fn add_event(&mut self, end: EventId)
sourcepub fn can_contain(&self, id: &EventId) -> bool
pub fn can_contain(&self, id: &EventId) -> bool
pub fn is_empty(&self) -> bool
pub fn events(&self) -> Iter<'_, EventId>
Trait Implementations§
source§impl Ord for Range
impl Ord for Range
source§impl PartialEq<Range> for Range
impl PartialEq<Range> for Range
source§impl PartialOrd<Range> for Range
impl PartialOrd<Range> for Range
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read more