Silk

silk/buffered_input

Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu-no-libc, wasm32-unknown-unknown, x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu-no-libc.

Fixed-capacity retained byte input for incremental protocol parsing.

Details

BufferedInput owns one reusable initialized allocation. peek borrows only the unread prefix; consume advances it explicitly, so bytes read beyond a protocol delimiter remain available.

Import as BufferedInput with import silk.buffered_input { BufferedInput }.

Public declarations: 5.

MAX_CAPACITY

pub const MAX_CAPACITY: usize

The largest allocation accepted by one buffered direction.

BufferError

pub union BufferError

A typed buffering, progress, or source-boundary failure.

InvalidCapacity

BufferError.InvalidCapacity { capacity: usize }: BufferError

Construction rejected a zero or excessive capacity before allocation.

Field capacity

pub capacity: usize

The rejected allocation size in bytes.

BufferTooSmall

BufferError.BufferTooSmall { requested: usize, capacity: usize }: BufferError

A fill request cannot fit in the fixed allocation.

Field requested

pub requested: usize

The minimum retained byte count requested.

Field capacity

pub capacity: usize

The fixed allocation size in bytes.

InvalidConsumption

BufferError.InvalidConsumption { requested: usize, available: usize }: BufferError

Consume would advance beyond the initialized unread prefix.

Field requested

pub requested: usize

The byte count requested for consumption.

Field available

pub available: usize

The initialized unread byte count.

InvalidReadCount

BufferError.InvalidReadCount { count: usize, limit: usize }: BufferError

An input provider reported an impossible successful count.

Field count

pub count: usize

The successful count reported by the provider.

Field limit

pub limit: usize

The destination length offered to the provider.

UnexpectedEnd

BufferError.UnexpectedEnd { progress: usize }: BufferError

Underlying end arrived before an exact operation completed.

Field progress

pub progress: usize

The exact prefix copied or discarded before end.

ReadFailed

BufferError.ReadFailed { progress: usize, error: ByteIoError }: BufferError

A ByteDuplex read failed after progress bytes had already been copied by this operation.

Field progress

pub progress: usize

The exact prefix copied before the failed read.

Field error

pub error: ByteIoError

The underlying duplex read failure.

InputFailed

BufferError.InputFailed { progress: usize, error: StreamReadError }: BufferError

A StandardInput read failed after progress bytes had already been copied by this operation.

Field progress

pub progress: usize

The exact prefix copied before the failed read.

Field error

pub error: StreamReadError

The underlying standard-input failure.

WriteFailed

BufferError.WriteFailed { accepted: usize, drained: usize, error: ByteIoError }: BufferError

A ByteDuplex write or flush failed after accepting a caller prefix and draining pending bytes.

Field accepted

pub accepted: usize

The exact current caller-input prefix accepted into buffered ownership.

Field drained

pub drained: usize

The exact pending prefix acknowledged by the transport during the failing drain operation.

Field error

pub error: ByteIoError

The underlying transport failure.

UnknownExternalTransfer

BufferError.UnknownExternalTransfer { progress: usize, error: WriterError }: BufferError

Writer failed an all-or-error call after earlier complete arguments were accepted.

Field progress

pub progress: usize

The bytes accepted before the failed Writer call; the failed call has unknown external progress.

Field error

pub error: WriterError

The underlying Writer failure.

LengthOverflow

BufferError.LengthOverflow: BufferError

Finite vector-length arithmetic overflowed before output.

Terminal

BufferError.Terminal: BufferError

A preceding external failure made the state unusable.

FillOutcome

pub union FillOutcome

The observable result of satisfying a minimum retained prefix.

Available

FillOutcome.Available { count: usize }: FillOutcome

At least the requested minimum is available.

Field count

pub count: usize

The initialized unread byte count.

End

FillOutcome.End { available: usize }: FillOutcome

The source ended; available retained bytes can still be consumed.

Field available

pub available: usize

The retained byte count still available after source end.

DiscardOutcome

pub struct DiscardOutcome

The result of a finite discard.

Field count

pub count: usize

The exact consumed byte count.

Field endObserved

pub endObserved: bool

True only when the operation actually observed source end.

BufferedInput

pub struct BufferedInput

One fixed-capacity retained input buffer.

Associated function BufferedInput.make

pub effect<'static> fn make(capacity: usize) -> BufferedInput ! BufferError | OutOfMemoryError ? &mut Allocator

Allocates and initializes one fixed-capacity input buffer.

Method BufferedInput.capacity

pub fn capacity<'life0>(self: &'life0 BufferedInput) -> usize

Returns the immutable fixed capacity.

Method BufferedInput.unread

pub fn unread<'life0>(self: &'life0 BufferedInput) -> usize

Returns the initialized unread count.

Method BufferedInput.isEnded

pub fn isEnded<'life0>(self: &'life0 BufferedInput) -> bool

Reports whether the source has reached sticky end.

Method BufferedInput.isTerminal

pub fn isTerminal<'life0>(self: &'life0 BufferedInput) -> bool

Reports whether an external failure made this input terminal.

Method BufferedInput.peek

pub fn peek<'a>(self: &'a BufferedInput) -> &'a [u8]

Borrows exactly the initialized unread slice.

Method BufferedInput.consume

pub effect<'life0> fn consume<'life0>(self: &'life0 mut BufferedInput, count: usize) -> () ! BufferError

Advances by count initialized bytes, preserving state on overrun.

Method BufferedInput.fill

pub effect<'life0> fn fill<'life0>(self: &'life0 mut BufferedInput, minimum: usize, deadline: silk/option.Option<silk/system_clock.Instant>) -> FillOutcome ! BufferError ? &mut ByteDuplex | &mut MonotonicClock

Retains at least minimum bytes or reports sticky source end.

Method BufferedInput.fillStandard

pub effect<'life0> fn fillStandard<'life0>(self: &'life0 mut BufferedInput, minimum: usize) -> FillOutcome ! BufferError ? &mut StandardInput

Retains through StandardInput without advertising a deadline.

Method BufferedInput.readSome

pub effect<'env> fn readSome<'life0: 'env, 'life1: 'env, 'env>(self: &'life0 mut BufferedInput, output: &'life1 mut [u8], deadline: silk/option.Option<silk/system_clock.Instant>) -> ReadTransfer ! BufferError ? &mut ByteDuplex | &mut MonotonicClock

Copies one positive prefix or reports sticky end.

Method BufferedInput.readSomeStandard

pub effect<'env> fn readSomeStandard<'life0: 'env, 'life1: 'env, 'env>(self: &'life0 mut BufferedInput, output: &'life1 mut [u8]) -> ReadTransfer ! BufferError ? &mut StandardInput

Copies one positive prefix through StandardInput or reports sticky end.

Method BufferedInput.readExact

pub effect<'env> fn readExact<'life0: 'env, 'life1: 'env, 'env>(self: &'life0 mut BufferedInput, output: &'life1 mut [u8], deadline: silk/option.Option<silk/system_clock.Instant>) -> () ! BufferError ? &mut ByteDuplex | &mut MonotonicClock

Fills the complete destination or reports its precisely copied prefix.

Method BufferedInput.discardAtMost

pub effect<'life0> fn discardAtMost<'life0>(self: &'life0 mut BufferedInput, limit: usize, deadline: silk/option.Option<silk/system_clock.Instant>) -> DiscardOutcome ! BufferError ? &mut ByteDuplex | &mut MonotonicClock

Discards no more than limit and reports whether end was actually observed.

Method BufferedInput.discardExact

pub effect<'life0> fn discardExact<'life0>(self: &'life0 mut BufferedInput, count: usize, deadline: silk/option.Option<silk/system_clock.Instant>) -> () ! BufferError ? &mut ByteDuplex | &mut MonotonicClock

Discards exactly count bytes or reports the consumed prefix at early end.

On this page