Skip to content

Commit

Permalink
[git-packetline] fix doc links
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed May 13, 2021
1 parent 1328c5b commit cf50f28
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
18 changes: 9 additions & 9 deletions git-packetline/src/immutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,27 @@ impl<'a> PacketLine<'a> {
}
}

/// Return this instance as slice if it's [`Data`][Borrowed::Data].
/// Return this instance as slice if it's [`Data`][PacketLine::Data].
pub fn as_slice(&self) -> Option<&[u8]> {
match self {
PacketLine::Data(d) => Some(d),
PacketLine::Flush | PacketLine::Delimiter | PacketLine::ResponseEnd => None,
}
}
/// Return this instance's [`as_slice()`][Borrowed::as_slice()] as [`BStr`].
/// Return this instance's [`as_slice()`][PacketLine::as_slice()] as [`BStr`].
pub fn as_bstr(&self) -> Option<&BStr> {
self.as_slice().map(Into::into)
}
/// Interpret this instance's [`as_slice()`][Borrowed::as_slice()] as [`Error`].
/// Interpret this instance's [`as_slice()`][PacketLine::as_slice()] as [`Error`].
///
/// This works for any data received in an error [channel][crate::Channel].
///
/// Note that this creates an unchecked error using the slice verbatim, which is useful to [serialize it][Error::to_write()].
/// See [`check_error()`][Borrowed::check_error()] for a version that assures the error information is in the expected format.
/// See [`check_error()`][PacketLine::check_error()] for a version that assures the error information is in the expected format.
pub fn to_error(&self) -> Option<Error<'_>> {
self.as_slice().map(Error)
}
/// Check this instance's [`as_slice()`][Borrowed::as_slice()] is a valid [`Error`] and return it.
/// Check this instance's [`as_slice()`][PacketLine::as_slice()] is a valid [`Error`] and return it.
///
/// This works for any data received in an error [channel][crate::Channel].
pub fn check_error(&self) -> Option<Error<'_>> {
Expand All @@ -64,10 +64,10 @@ impl<'a> PacketLine<'a> {
self.as_slice().map(Into::into)
}

/// Interpret the data in this [`slice`][Borrowed::as_slice()] as [`Band`] according to the given `kind` of channel.
/// Interpret the data in this [`slice`][PacketLine::as_slice()] as [`Band`] according to the given `kind` of channel.
///
/// Note that this is only relevant in a side-band channel.
/// See [`decode_band()`][Borrowed::decode_band()] in case `kind` is unknown.
/// See [`decode_band()`][PacketLine::decode_band()] in case `kind` is unknown.
pub fn to_band(&self, kind: Channel) -> Option<Band<'_>> {
self.as_slice().map(|d| match kind {
Channel::Data => Band::Data(d),
Expand All @@ -76,7 +76,7 @@ impl<'a> PacketLine<'a> {
})
}

/// Decode the band of this [`slice`][Borrowed::as_slice()], or panic if it is not actually a side-band line.
/// Decode the band of this [`slice`][PacketLine::as_slice()], or panic if it is not actually a side-band line.
pub fn decode_band(&self) -> Result<Band<'_>, DecodeBandError> {
let d = self.as_slice().ok_or(DecodeBandError::NonDataLine)?;
Ok(match d[0] {
Expand All @@ -90,7 +90,7 @@ impl<'a> PacketLine<'a> {

use quick_error::quick_error;
quick_error! {
/// The error used in [`decode_band()`][Borrowed::decode_band()].
/// The error used in [`decode_band()`][PacketLine::decode_band()].
#[derive(Debug)]
#[allow(missing_docs)]
pub enum DecodeBandError {
Expand Down
2 changes: 1 addition & 1 deletion git-packetline/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Read and write the git packet line wire format without copying it.
//!
//! For reading the packet line format use the [`Provider`], and for writing the `Writer`.
//! For reading the packet line format use the [`StreamingPeekableIter`], and for writing the `Writer`.
#![forbid(unsafe_code)]
#![deny(rust_2018_idioms, missing_docs)]

Expand Down
14 changes: 7 additions & 7 deletions git-packetline/src/read/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ where
}

/// Returns the packet line that stopped the iteration, or
/// `None` if the end wasn't reached yet, on EOF, or if [`fail_on_err_lines()`][Provider::fail_on_err_lines()] was true.
/// `None` if the end wasn't reached yet, on EOF, or if [`fail_on_err_lines()`][StreamingPeekableIter::fail_on_err_lines()] was true.
pub fn stopped_at(&self) -> Option<PacketLine<'static>> {
self.stopped_at
}
Expand All @@ -65,7 +65,7 @@ where
self.reset_with(delimiters);
}

/// Similar to [`reset()`][Provider::reset()] with support to changing the `delimiters`.
/// Similar to [`reset()`][StreamingPeekableIter::reset()] with support to changing the `delimiters`.
pub fn reset_with(&mut self, delimiters: &'static [PacketLine<'static>]) {
self.delimiters = delimiters;
self.is_done = false;
Expand All @@ -74,7 +74,7 @@ where

/// If `value` is `true` the provider will check for special `ERR` packet lines and stop iteration when one is encountered.
///
/// Use [`stopped_at()]`[Provider::stopped_at()] to inspect the cause of the end of the iteration.
/// Use [`stopped_at()]`[StreamingPeekableIter::stopped_at()] to inspect the cause of the end of the iteration.
/// ne
pub fn fail_on_err_lines(&mut self, value: bool) {
self.fail_on_err_lines = value;
Expand Down Expand Up @@ -148,7 +148,7 @@ where
/// Returns `None` if the end of iteration is reached because of one of the following:
///
/// * natural EOF
/// * ERR packet line encountered if [`fail_on_err_lines()`][Provider::fail_on_err_lines()] is true.
/// * ERR packet line encountered if [`fail_on_err_lines()`][StreamingPeekableIter::fail_on_err_lines()] is true.
/// * A `delimiter` packet line encountered
pub fn read_line(&mut self) -> Option<io::Result<Result<PacketLine<'_>, decode::Error>>> {
if self.is_done {
Expand Down Expand Up @@ -226,15 +226,15 @@ where
WithSidebands::with_progress_handler(self, handle_progress)
}

/// Same as [`as_read_with_sidebands(…)`][Provider::as_read_with_sidebands()], but for channels without side band support.
/// Same as [`as_read_with_sidebands(…)`][StreamingPeekableIter::as_read_with_sidebands()], but for channels without side band support.
///
/// The type parameter `F` needs to be configured for this method to be callable using the 'turbofish' operator.
/// Use [`as_read()`][Provider::as_read()].
/// Use [`as_read()`][StreamingPeekableIter::as_read()].
pub fn as_read_without_sidebands<F: FnMut(bool, &[u8])>(&mut self) -> WithSidebands<'_, T, F> {
WithSidebands::without_progress_handler(self)
}

/// Same as [`as_read_with_sidebands(…)`][Provider::as_read_with_sidebands()], but for channels without side band support.
/// Same as [`as_read_with_sidebands(…)`][StreamingPeekableIter::as_read_with_sidebands()], but for channels without side band support.
///
/// Due to the preconfigured function type this method can be called without 'turbofish'.
pub fn as_read(&mut self) -> WithSidebands<'_, T, fn(bool, &[u8])> {
Expand Down
6 changes: 3 additions & 3 deletions git-packetline/src/read/sidebands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ where
}
}

/// Forwards to the parent [Provider::reset_with()]
/// Forwards to the parent [StreamingPeekableIter::reset_with()]
pub fn reset_with(&mut self, delimiters: &'static [PacketLine<'static>]) {
self.parent.reset_with(delimiters)
}

/// Forwards to the parent [Provider::stopped_at()]
/// Forwards to the parent [StreamingPeekableIter::stopped_at()]
pub fn stopped_at(&self) -> Option<PacketLine<'static>> {
self.parent.stopped_at
}
Expand All @@ -93,7 +93,7 @@ where
self.handle_progress = handle_progress;
}

/// Effectively forwards to the parent [Provider::peek_line()], allowing to see what would be returned
/// Effectively forwards to the parent [StreamingPeekableIter::peek_line()], allowing to see what would be returned
/// next on a call to [`read_line()`][io::BufRead::read_line()].
pub fn peek_data_line(&mut self) -> Option<io::Result<Result<&[u8], crate::decode::Error>>> {
match self.parent.peek_line() {
Expand Down

0 comments on commit cf50f28

Please sign in to comment.