Skip to main content

Output

Trait Output 

Source
pub trait Output {
    type Item;

    // Required methods
    unsafe fn write_unchecked(
        &mut self,
        input: &[Self::Item],
        index: usize,
        count: usize,
    ) -> Result<usize>;
    fn flush(&mut self) -> Result<()>;
}
Expand description

Minimal indexed output interface over units.

Output is intentionally smaller and lower-level than Write. It only states that an implementor can write up to count units from input[index..index + count], plus an explicit flush operation. The caller owns range validation so hot paths can avoid repeated slicing and bounds checks.

Required Associated Types§

Source

type Item

The unit type written to this output.

Required Methods§

Source

unsafe fn write_unchecked( &mut self, input: &[Self::Item], index: usize, count: usize, ) -> Result<usize>

Writes units from an indexed input range without checking the range.

§Parameters
  • input - Source storage.
  • index - Start index inside input.
  • count - Maximum number of units to write.
§Returns

The number of units accepted from input[index..index + count]. The value must be in 0..=count.

§Errors

Returns the output error reported by the implementation.

§Safety

The caller must guarantee that index..index + count is a valid range inside input and that the addition does not overflow.

Source

fn flush(&mut self) -> Result<()>

Flushes any internally buffered units.

§Errors

Returns the output error reported by the implementation.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<W> Output for W
where W: Write + ?Sized,