bndpresbufch 0.1.2

Bounds-preserving channel for passing buffers.
Documentation
use std::fmt;

/// Crate-specific errors.
#[derive(Debug, PartialEq, Eq)]
pub enum Error {
  /// No remote end-points.
  ///
  /// For transmitting functions, this means all the receivers have been
  /// dropped.  For receiving functions that would wait for new buffers, this
  /// means all the senders have been dropped.
  Closed,

  /// Returned if the queue is full (either with regard to length or size) for
  /// _try push_ operations.  Returned by _force push_  operations if the
  /// buffer size exceeds the total queue buffer size limit.
  WontFit(Vec<u8>)
}

impl std::error::Error for Error {}

impl fmt::Display for Error {
  fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
    match self {
      Self::Closed => write!(f, "Remote end-point has closed"),
      Self::WontFit(_buf) => write!(f, "Buffer will not fit")
    }
  }
}

// vim: set ft=rust et sw=2 ts=2 sts=2 cinoptions=2 tw=79 :