Lines Matching defs:TimeVal

453 pub struct TimeVal(timeval);
465 impl AsRef<timeval> for TimeVal {
471 impl AsMut<timeval> for TimeVal {
477 impl Ord for TimeVal {
480 fn cmp(&self, other: &TimeVal) -> cmp::Ordering {
489 impl PartialOrd for TimeVal {
490 fn partial_cmp(&self, other: &TimeVal) -> Option<cmp::Ordering> {
495 impl TimeValLike for TimeVal {
497 fn seconds(seconds: i64) -> TimeVal {
500 "TimeVal out of bounds; seconds={}",
505 TimeVal(timeval {
512 fn milliseconds(milliseconds: i64) -> TimeVal {
515 .expect("TimeVal::milliseconds out of bounds");
517 TimeVal::microseconds(microseconds)
520 /// Makes a new `TimeVal` with given number of microseconds.
522 fn microseconds(microseconds: i64) -> TimeVal {
526 "TimeVal out of bounds"
530 TimeVal(timeval {
536 /// Makes a new `TimeVal` with given number of nanoseconds. Some precision
539 fn nanoseconds(nanoseconds: i64) -> TimeVal {
544 "TimeVal out of bounds"
548 TimeVal(timeval {
581 impl TimeVal {
582 /// Construct a new `TimeVal` from its components
609 impl ops::Neg for TimeVal {
610 type Output = TimeVal;
612 fn neg(self) -> TimeVal {
613 TimeVal::microseconds(-self.num_microseconds())
617 impl ops::Add for TimeVal {
618 type Output = TimeVal;
620 fn add(self, rhs: TimeVal) -> TimeVal {
621 TimeVal::microseconds(self.num_microseconds() + rhs.num_microseconds())
625 impl ops::Sub for TimeVal {
626 type Output = TimeVal;
628 fn sub(self, rhs: TimeVal) -> TimeVal {
629 TimeVal::microseconds(self.num_microseconds() - rhs.num_microseconds())
633 impl ops::Mul<i32> for TimeVal {
634 type Output = TimeVal;
636 fn mul(self, rhs: i32) -> TimeVal {
640 .expect("TimeVal multiply out of bounds");
642 TimeVal::microseconds(usec)
646 impl ops::Div<i32> for TimeVal {
647 type Output = TimeVal;
649 fn div(self, rhs: i32) -> TimeVal {
651 TimeVal::microseconds(usec)
655 impl fmt::Display for TimeVal {
683 impl From<timeval> for TimeVal {
685 TimeVal(tv)
717 use super::{TimeSpec, TimeVal, TimeValLike};
774 assert_ne!(TimeVal::seconds(1), TimeVal::zero());
776 TimeVal::seconds(1) + TimeVal::seconds(2),
777 TimeVal::seconds(3)
780 TimeVal::minutes(3) + TimeVal::seconds(2),
781 TimeVal::seconds(182)
787 assert_eq!(TimeVal::seconds(1), TimeVal::microseconds(1_000_000));
788 assert!(TimeVal::seconds(1) < TimeVal::microseconds(1_000_001));
789 assert!(TimeVal::seconds(1) > TimeVal::microseconds(999_999));
790 assert!(TimeVal::seconds(-1) < TimeVal::microseconds(-999_999));
791 assert!(TimeVal::seconds(-1) > TimeVal::microseconds(-1_000_001));
796 let a = TimeVal::seconds(1) + TimeVal::microseconds(123);
797 let b = TimeVal::seconds(-1) + TimeVal::microseconds(-123);
804 assert_eq!(TimeVal::zero().to_string(), "0 seconds");
805 assert_eq!(TimeVal::seconds(42).to_string(), "42 seconds");
806 assert_eq!(TimeVal::milliseconds(42).to_string(), "0.042 seconds");
807 assert_eq!(TimeVal::microseconds(42).to_string(), "0.000042 seconds");
808 assert_eq!(TimeVal::nanoseconds(1402).to_string(), "0.000001 seconds");
809 assert_eq!(TimeVal::seconds(-86401).to_string(), "-86401 seconds");