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: usizeThe largest allocation accepted by one buffered direction.
BufferError
pub union BufferErrorA typed buffering, progress, or source-boundary failure.
InvalidCapacity
BufferError.InvalidCapacity { capacity: usize }: BufferErrorConstruction rejected a zero or excessive capacity before allocation.
Field capacity
pub capacity: usizeThe rejected allocation size in bytes.
BufferTooSmall
BufferError.BufferTooSmall { requested: usize, capacity: usize }: BufferErrorA fill request cannot fit in the fixed allocation.
Field requested
pub requested: usizeThe minimum retained byte count requested.
Field capacity
pub capacity: usizeThe fixed allocation size in bytes.
InvalidConsumption
BufferError.InvalidConsumption { requested: usize, available: usize }: BufferErrorConsume would advance beyond the initialized unread prefix.
Field requested
pub requested: usizeThe byte count requested for consumption.
Field available
pub available: usizeThe initialized unread byte count.
InvalidReadCount
BufferError.InvalidReadCount { count: usize, limit: usize }: BufferErrorAn input provider reported an impossible successful count.
Field count
pub count: usizeThe successful count reported by the provider.
Field limit
pub limit: usizeThe destination length offered to the provider.
UnexpectedEnd
BufferError.UnexpectedEnd { progress: usize }: BufferErrorUnderlying end arrived before an exact operation completed.
Field progress
pub progress: usizeThe exact prefix copied or discarded before end.
ReadFailed
BufferError.ReadFailed { progress: usize, error: ByteIoError }: BufferErrorA ByteDuplex read failed after progress bytes had already been copied by this operation.
Field progress
pub progress: usizeThe exact prefix copied before the failed read.
Field error
pub error: ByteIoErrorThe underlying duplex read failure.
InputFailed
BufferError.InputFailed { progress: usize, error: StreamReadError }: BufferErrorA StandardInput read failed after progress bytes had already been copied by this operation.
Field progress
pub progress: usizeThe exact prefix copied before the failed read.
Field error
pub error: StreamReadErrorThe underlying standard-input failure.
WriteFailed
BufferError.WriteFailed { accepted: usize, drained: usize, error: ByteIoError }: BufferErrorA ByteDuplex write or flush failed after accepting a caller prefix and draining pending bytes.
Field accepted
pub accepted: usizeThe exact current caller-input prefix accepted into buffered ownership.
Field drained
pub drained: usizeThe exact pending prefix acknowledged by the transport during the failing drain operation.
Field error
pub error: ByteIoErrorThe underlying transport failure.
UnknownExternalTransfer
BufferError.UnknownExternalTransfer { progress: usize, error: WriterError }: BufferErrorWriter failed an all-or-error call after earlier complete arguments were accepted.
Field progress
pub progress: usizeThe bytes accepted before the failed Writer call; the failed call has unknown external progress.
Field error
pub error: WriterErrorThe underlying Writer failure.
LengthOverflow
BufferError.LengthOverflow: BufferErrorFinite vector-length arithmetic overflowed before output.
Terminal
BufferError.Terminal: BufferErrorA preceding external failure made the state unusable.
FillOutcome
pub union FillOutcomeThe observable result of satisfying a minimum retained prefix.
Available
FillOutcome.Available { count: usize }: FillOutcomeAt least the requested minimum is available.
Field count
pub count: usizeThe initialized unread byte count.
End
FillOutcome.End { available: usize }: FillOutcomeThe source ended; available retained bytes can still be consumed.
Field available
pub available: usizeThe retained byte count still available after source end.
DiscardOutcome
pub struct DiscardOutcomeThe result of a finite discard.
Field count
pub count: usizeThe exact consumed byte count.
Field endObserved
pub endObserved: boolTrue only when the operation actually observed source end.
BufferedInput
pub struct BufferedInputOne fixed-capacity retained input buffer.
Associated function BufferedInput.make
pub effect<'static> fn make(capacity: usize) -> BufferedInput ! BufferError | OutOfMemoryError ? &mut AllocatorAllocates and initializes one fixed-capacity input buffer.
Method BufferedInput.capacity
pub fn capacity<'life0>(self: &'life0 BufferedInput) -> usizeReturns the immutable fixed capacity.
Method BufferedInput.unread
pub fn unread<'life0>(self: &'life0 BufferedInput) -> usizeReturns the initialized unread count.
Method BufferedInput.isEnded
pub fn isEnded<'life0>(self: &'life0 BufferedInput) -> boolReports whether the source has reached sticky end.
Method BufferedInput.isTerminal
pub fn isTerminal<'life0>(self: &'life0 BufferedInput) -> boolReports 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) -> () ! BufferErrorAdvances 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 MonotonicClockRetains 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 StandardInputRetains 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 MonotonicClockCopies 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 StandardInputCopies 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 MonotonicClockFills 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 MonotonicClockDiscards 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 MonotonicClockDiscards exactly count bytes or reports the consumed prefix at early end.