-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1091 from eclipse-zenoh/new_reception_timestamp
session id parameter added to new_timestamp, renaming
- Loading branch information
Showing
10 changed files
with
43 additions
and
19 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,16 +11,13 @@ | |
// Contributors: | ||
// ZettaScale Zenoh Team, <[email protected]> | ||
// | ||
use std::convert::TryFrom; | ||
use std::time::{SystemTime, UNIX_EPOCH}; | ||
|
||
use zenoh_protocol::core::{Timestamp, TimestampId}; | ||
|
||
/// Generates a reception [`Timestamp`] with id=0x01. | ||
/// This operation should be called if a timestamp is required for an incoming [`zenoh::Sample`](crate::Sample) | ||
/// that doesn't contain any timestamp. | ||
pub fn new_reception_timestamp() -> Timestamp { | ||
use std::time::{SystemTime, UNIX_EPOCH}; | ||
|
||
let now = SystemTime::now().duration_since(UNIX_EPOCH).unwrap(); | ||
Timestamp::new(now.into(), TimestampId::try_from([1]).unwrap()) | ||
/// Generates a [`Timestamp`] with [`TimestampId`] and current system time | ||
/// The [`TimestampId`] can be taken from session id returned by [`SessionInfo::zid()`](crate::api::info::SessionInfo::zid). | ||
pub fn new_timestamp<T: Into<TimestampId>>(id: T) -> Timestamp { | ||
let now = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().into(); | ||
Timestamp::new(now, id.into()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters