From 57f245da290fee5a1cb2e9526fd30df3a2fb379d Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sat, 4 Dec 2021 03:50:22 -0500 Subject: fix doc links --- src/blocking/reader.rs | 12 ++++++------ src/blocking/writer.rs | 12 ++++++------ src/creator.rs | 23 ++++++++++++----------- src/frame.rs | 4 ++-- src/lib.rs | 10 ++++++---- src/parser.rs | 13 +++++++------ src/reader.rs | 13 +++++++------ src/writer.rs | 13 +++++++------ 8 files changed, 53 insertions(+), 47 deletions(-) (limited to 'src') diff --git a/src/blocking/reader.rs b/src/blocking/reader.rs index 86c348d..609c393 100644 --- a/src/blocking/reader.rs +++ b/src/blocking/reader.rs @@ -1,4 +1,4 @@ -/// Reads ttyrec frames from a `std::io::Read` instance. +/// Reads ttyrec frames from a [`std::io::Read`] instance. pub struct Reader { input: T, parser: crate::Parser, @@ -6,7 +6,7 @@ pub struct Reader { } impl Reader { - /// Creates a new `Reader` from a `std::io::Read` instance. + /// Creates a new [`Reader`] from a [`std::io::Read`] instance. pub fn new(input: T) -> Self { Self { input, @@ -18,9 +18,9 @@ impl Reader { /// Returns the next parsed frame from the input stream. /// /// # Errors - /// * `crate::Error::EOF`: The input stream has been closed. - /// * `crate::Error::Read`: There was an error reading from the input - /// stream. + /// * [`Error::EOF`](crate::Error::EOF): The input stream has been closed. + /// * [`Error::Read`](crate::Error::Read): There was an error reading from + /// the input stream. pub fn read_frame(&mut self) -> crate::Result { loop { if let Some(frame) = self.parser.next_frame() { @@ -39,7 +39,7 @@ impl Reader { /// How much the timestamps in this file should be offset by. /// - /// See `Parser::offset`. + /// See [`Parser::offset`](crate::Parser::offset). pub fn offset(&self) -> Option { self.parser.offset() } diff --git a/src/blocking/writer.rs b/src/blocking/writer.rs index 5dade25..c9fdb7d 100644 --- a/src/blocking/writer.rs +++ b/src/blocking/writer.rs @@ -1,11 +1,11 @@ -/// Writes ttyrec frames to a `std::io::Write` instance. +/// Writes ttyrec frames to a [`std::io::Write`] instance. pub struct Writer { output: T, creator: crate::Creator, } impl Writer { - /// Creates a new `Writer` from a `std::io::Write` instance. + /// Creates a new [`Writer`] from a [`std::io::Write`] instance. pub fn new(output: T) -> Self { Self { output, @@ -17,8 +17,8 @@ impl Writer { /// given data. /// /// # Errors - /// * `crate::Error::Write`: There was an error writing to the input - /// stream. + /// * [`Error::Write`](crate::Error::Write): There was an error writing to + /// the input stream. pub fn frame(&mut self, data: &[u8]) -> crate::Result<()> { self.frame_at(std::time::Instant::now(), data) } @@ -27,8 +27,8 @@ impl Writer { /// data. /// /// # Errors - /// * `crate::Error::Write`: There was an error writing to the input - /// stream. + /// * [`crate::Error::Write`](crate::Error::Write): There was an error + /// writing to the input stream. pub fn frame_at( &mut self, cur_time: std::time::Instant, diff --git a/src/creator.rs b/src/creator.rs index f4745cc..590d282 100644 --- a/src/creator.rs +++ b/src/creator.rs @@ -1,35 +1,36 @@ /// 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. +/// [`Frame`](crate::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, } impl Creator { - /// Creates a new `Creator` instance. + /// Creates a new [`Creator`] instance. #[must_use] pub fn new() -> Self { Self::default() } - /// Returns a new `Frame` object containing the given data. + /// Returns a new [`Frame`](crate::Frame) object containing the given + /// data. /// - /// Equivalent to calling `frame_at` and passing - /// `std::time::Instant::now()` as the `cur_time` parameter. + /// Equivalent to calling [`frame_at`](Self::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. + /// Returns a new [`Frame`](crate::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. + /// `cur_time` parameters given in each [`frame_at`](Self::frame_at) call + /// are non-decreasing. #[allow(clippy::missing_panics_doc)] pub fn frame_at( &mut self, diff --git a/src/frame.rs b/src/frame.rs index 71b3988..5996409 100644 --- a/src/frame.rs +++ b/src/frame.rs @@ -5,8 +5,8 @@ /// is relevant. The base timestamp can be anything (common choices are 0 or /// the actual time that the frame was generated). /// -/// Frame objects are typically created via the `Creator`, `Parser`, or -/// `Reader` classes. +/// Frame objects are typically created via the [`Creator`](crate::Creator), +/// [`Parser`](crate::Parser), or [`Reader`](crate::Reader) classes. #[derive(Debug, Clone, PartialEq, Eq)] pub struct Frame { /// Amount of time passed since the start of the ttyrec file. diff --git a/src/lib.rs b/src/lib.rs index 5efd824..c7a43ec 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,11 +3,13 @@ //! //! `Parser` and `Creator` can be used to read and write files manually, and //! `Reader` and `Writer` are helpers to provide a nicer API for asynchronous -//! applications using `tokio`. +//! applications using futures. Additionally, `blocking::Reader` and +//! `blocking::Writer` provide a similar API for non-asynchronous +//! applications. //! -//! If you are not using `tokio`, the `tokio` dependencies can be removed by -//! building with `default_features = false` (by default, the `"async"` -//! feature is enabled which provides `tokio` support). +//! If you do not need the async API, the `futures` dependency can be removed +//! by building with `default_features = false` (by default, the `"async"` +//! feature is enabled). // XXX this is broken with ale // #![warn(clippy::cargo)] diff --git a/src/parser.rs b/src/parser.rs index 126eae3..9887b38 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -22,9 +22,10 @@ impl Header { /// /// Designed to be able to be used in a streaming/asynchronous fashion. As you /// read bytes from the ttyrec stream (whether from a file or whatever else), -/// call the `add_bytes` method to add them to the internal buffer. At any -/// point, you can call `next_frame` to then return the next complete frame if -/// one has been read. +/// call the [`add_bytes`](Parser::add_bytes) method to add them to the +/// internal buffer. At any point, you can call +/// [`next_frame`](Parser::next_frame) to then return the next complete frame +/// if one has been read. #[derive(Debug, Default, Clone)] pub struct Parser { reading: std::collections::VecDeque, @@ -33,7 +34,7 @@ pub struct Parser { } impl Parser { - /// Create a new `Parser`. + /// Create a new [`Parser`](Self). #[must_use] pub fn new() -> Self { Self::default() @@ -48,7 +49,7 @@ impl Parser { /// /// If a complete frame is found, the bytes for that frame will be removed /// from the internal buffer and the frame object will be returned. If a - /// complete frame is not found, this method will return `None`. + /// complete frame is not found, this method will return [`None`]. #[allow(clippy::missing_panics_doc)] pub fn next_frame(&mut self) -> Option { let header = if let Some(header) = &self.read_state { @@ -108,7 +109,7 @@ impl Parser { /// need to take the timestamp of the first frame as the start time, and /// each frame timestamp after that should be offset by that same amount. /// - /// Returns `None` if no frames have been read yet. + /// Returns [`None`] if no frames have been read yet. #[must_use] pub fn offset(&self) -> Option { self.offset diff --git a/src/reader.rs b/src/reader.rs index 6641bb9..240c78e 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -1,6 +1,6 @@ use futures::io::AsyncReadExt as _; -/// Reads ttyrec frames from a `futures::io::AsyncRead` instance. +/// Reads ttyrec frames from a [`futures::io::AsyncRead`] instance. pub struct Reader { input: T, parser: crate::Parser, @@ -8,7 +8,8 @@ pub struct Reader { } impl Reader { - /// Creates a new `Reader` from a `futures::io::AsyncRead` instance. + /// Creates a new [`Reader`](Self) from a [`futures::io::AsyncRead`] + /// instance. pub fn new(input: T) -> Self { Self { input, @@ -20,9 +21,9 @@ impl Reader { /// Returns the next parsed frame from the input stream. /// /// # Errors - /// * `crate::Error::EOF`: The input stream has been closed. - /// * `crate::Error::Read`: There was an error reading from the input - /// stream. + /// * [`Error::EOF`](crate::Error::EOF): The input stream has been closed. + /// * [`Error::Read`](crate::Error::Read): There was an error reading from + /// the input stream. pub async fn read_frame(&mut self) -> crate::Result { loop { if let Some(frame) = self.parser.next_frame() { @@ -42,7 +43,7 @@ impl Reader { /// How much the timestamps in this file should be offset by. /// - /// See `Parser::offset`. + /// See [`Parser::offset`](crate::Parser::offset). pub fn offset(&self) -> Option { self.parser.offset() } diff --git a/src/writer.rs b/src/writer.rs index 6975ad1..f161df0 100644 --- a/src/writer.rs +++ b/src/writer.rs @@ -1,13 +1,14 @@ use futures::io::AsyncWriteExt as _; -/// Writes ttyrec frames to a `futures::io::AsyncWrite` instance. +/// Writes ttyrec frames to a [`futures::io::AsyncWrite`] instance. pub struct Writer { output: T, creator: crate::Creator, } impl Writer { - /// Creates a new `Writer` from a `futures::io::AsyncWrite` instance. + /// Creates a new [`Writer`](Self) from a [`futures::io::AsyncWrite`] + /// instance. pub fn new(output: T) -> Self { Self { output, @@ -19,8 +20,8 @@ impl Writer { /// given data. /// /// # Errors - /// * `crate::Error::Write`: There was an error writing to the input - /// stream. + /// * [`Error::Write`](crate::Error::Write): There was an error writing to + /// the input stream. pub async fn frame(&mut self, data: &[u8]) -> crate::Result<()> { self.frame_at(std::time::Instant::now(), data).await } @@ -29,8 +30,8 @@ impl Writer { /// data. /// /// # Errors - /// * `crate::Error::Write`: There was an error writing to the input - /// stream. + /// * [`Error::Write`](crate::Error::Write): There was an error writing to + /// the input stream. pub async fn frame_at( &mut self, cur_time: std::time::Instant, -- cgit v1.2.3-54-g00ecf