diff options
author | Jesse Luehrs <doy@tozt.net> | 2019-10-27 08:07:09 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2019-10-27 08:07:09 -0400 |
commit | 17fc6b3eda370f99fee48420532ada8b497ecd8c (patch) | |
tree | cf8067dc80e700bf3056e22e86942e13e4fd3795 /src/creator.rs | |
parent | 9739318498f8b78788923986d77a7b436d6af12a (diff) | |
download | ttyrec-17fc6b3eda370f99fee48420532ada8b497ecd8c.tar.gz ttyrec-17fc6b3eda370f99fee48420532ada8b497ecd8c.zip |
docs
Diffstat (limited to 'src/creator.rs')
-rw-r--r-- | src/creator.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/creator.rs b/src/creator.rs index fb228dd..c0f9b76 100644 --- a/src/creator.rs +++ b/src/creator.rs @@ -1,17 +1,34 @@ +/// Creates ttyrec frames. +/// +/// A ttyrec file is a stream of concatenated frames. This struct creates +/// `Frame` objects, which can be serialized to bytes using their `try_from` +/// implementation, and then a ttyrec file can be generated by concatenating +/// those byte strings. #[derive(Debug, Clone)] pub struct Creator { base_time: Option<std::time::Instant>, } impl Creator { + /// Creates a new `Creator` instance. pub fn new() -> Self { Default::default() } + /// Returns a new `Frame` object containing the given data. + /// + /// Equivalent to calling `frame_at` and passing + /// `std::time::Instant::now()` as the `cur_time` parameter. pub fn frame(&mut self, data: &[u8]) -> crate::frame::Frame { self.frame_at(std::time::Instant::now(), data) } + /// Returns a new `Frame` object containing the given data at the given + /// time. + /// + /// Note that this is not guaranteed to do the correct thing unless the + /// `cur_time` parameters given in each `frame_at` call are + /// non-decreasing. pub fn frame_at( &mut self, cur_time: std::time::Instant, |