pub trait ChunkCapacity {
    // Required method
    fn end(&self) -> usize;

    // Provided methods
    fn start(&self) -> Option<usize> { ... }
    fn fits(&self, chunk_size: usize) -> Ordering { ... }
}
Expand description

Describes the largest valid chunk size(s) that can be generated.

An end size is required, which is the maximum possible chunk size that can be generated.

A start size is optional. By specifying start and end it means a range of sizes will be considered valid. Once a chunk has reached a length that falls between start and end it will be returned.

It is always possible that a chunk may be returned that is less than the start value, as adding the next piece of text may have made it larger than the end capacity.

Required Methods§

source

fn end(&self) -> usize

The maximum size that a chunk can be.

Provided Methods§

source

fn start(&self) -> Option<usize>

An optional start value. If both start and end are specified, a valid chunk can fall anywhere between the two values (inclusive).

source

fn fits(&self, chunk_size: usize) -> Ordering

Validate if a given chunk fits within the capacity

  • Ordering::Less indicates more could be added
  • Ordering::Equal indicates the chunk is within the capacity range
  • Ordering::Greater indicates the chunk is larger than the capacity

Implementations on Foreign Types§

source§

impl ChunkCapacity for usize

source§

fn end(&self) -> usize

source§

impl ChunkCapacity for Range<usize>

source§

fn start(&self) -> Option<usize>

source§

fn end(&self) -> usize

source§

impl ChunkCapacity for RangeFrom<usize>

source§

fn start(&self) -> Option<usize>

source§

fn end(&self) -> usize

source§

impl ChunkCapacity for RangeFull

source§

fn start(&self) -> Option<usize>

source§

fn end(&self) -> usize

source§

impl ChunkCapacity for RangeInclusive<usize>

source§

fn start(&self) -> Option<usize>

source§

fn end(&self) -> usize

source§

impl ChunkCapacity for RangeTo<usize>

source§

fn start(&self) -> Option<usize>

source§

fn end(&self) -> usize

source§

impl ChunkCapacity for RangeToInclusive<usize>

source§

fn start(&self) -> Option<usize>

source§

fn end(&self) -> usize

Implementors§