silk/byte_duplex
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.
Partial reliable-byte input and output with explicit deadlines and directional shutdown.
When to use
Require ByteDuplex when a protocol driver owns its buffers and must acknowledge exact
transport prefixes. Use silk.writer.Writer when each write is all-or-error.
Details
Each nonempty successful transfer reports one positive prefix. Bytes after that prefix remain
with the caller. Deadlines are absolute marks from the active MonotonicClock provider.
ReadTransfer.End is transport end. It is not a protocol close message.
Gotchas
An invalid provider count makes the lease unusable. A canceled external transfer can also make ownership ambiguous. Close such a lease and do not retry its last buffer.
Import as ByteDuplex with import silk.byte_duplex { ByteDuplex }.
Public declarations: 4.
ByteIoOperation
pub enum ByteIoOperationThe operation associated with one portable byte-I/O failure.
Read
Read = 0A partial input transfer.
Write
Write = 1A partial output transfer.
Flush
Flush = 2A transport-boundary flush.
ShutdownWrite
ShutdownWrite = 3A write-direction shutdown.
Close
Close = 4A terminal duplex close.
ByteIoError
pub union ByteIoErrorA typed failure from one ByteDuplex operation.
Timeout
ByteIoError.Timeout { operation: ByteIoOperation }: ByteIoErrorThe absolute monotonic deadline was reached.
Field operation
pub operation: ByteIoOperationThe operation that reached its deadline.
InvalidTransferCount
ByteIoError.InvalidTransferCount { operation: ByteIoOperation, count: usize, limit: usize }: ByteIoErrorThe provider reported an impossible successful prefix.
Field operation
pub operation: ByteIoOperationThe operation that reported the count.
Field count
pub count: usizeThe count reported by the provider.
Field limit
pub limit: usizeThe caller buffer length for that transfer.
Closed
ByteIoError.Closed { operation: ByteIoOperation }: ByteIoErrorThe requested direction or complete lease is closed.
Field operation
pub operation: ByteIoOperationThe operation rejected after closure.
Provider
ByteIoError.Provider { operation: ByteIoOperation, code: i32 }: ByteIoErrorThe provider rejected an otherwise valid operation.
Field operation
pub operation: ByteIoOperationThe rejected operation.
Field code
pub code: i32One provider-defined diagnostic code.
ReadTransfer
pub union ReadTransferThe result of one partial input operation.
Data
ReadTransfer.Data { count: usize }: ReadTransferA positive prefix of the output slice now contains input bytes.
Field count
pub count: usizeThe exact initialized prefix length.
End
ReadTransfer.End: ReadTransferThe underlying transport reached orderly end-of-input.
ByteDuplex
pub service ByteDuplexUnsafe provider hooks for one exclusive reliable-byte transport.
Details
Ordinary callers use the safe inherent operations with the corresponding names. Provider implementations satisfy these hooks; calling one directly acknowledges that its raw transfer count has not passed the canonical boundary validation.
Operation readSomeRaw
unsafe effect<'life0> fn readSomeRaw<'life0>(output: &'life0 mut [u8], deadline: silk/option.Option<silk/system_clock.Instant>) -> ReadTransfer ! ByteIoError ? &mut ByteDuplex | &mut MonotonicClockPerforms one provider read before canonical transfer validation.
Operation writeSomeRaw
unsafe effect<'life0> fn writeSomeRaw<'life0>(input: &'life0 [u8], deadline: silk/option.Option<silk/system_clock.Instant>) -> usize ! ByteIoError ? &mut ByteDuplex | &mut MonotonicClockPerforms one provider write before canonical transfer validation.
Operation flushRaw
unsafe effect<'static> fn flushRaw(deadline: silk/option.Option<silk/system_clock.Instant>) -> () ! ByteIoError ? &mut ByteDuplex | &mut MonotonicClockPerforms the provider's transport-boundary flush.
Operation shutdownWriteRaw
unsafe effect<'static> fn shutdownWriteRaw(deadline: silk/option.Option<silk/system_clock.Instant>) -> () ! ByteIoError ? &mut ByteDuplex | &mut MonotonicClockCloses only the provider's write direction after the canonical wrapper has flushed.
Operation closeRaw
unsafe effect<'static> fn closeRaw() -> () ! ByteIoError ? &mut ByteDuplex with Intrinsic.nonParking()Closes the complete transport lease. Implementations must remain terminal and idempotent.
Associated function ByteDuplex.readSome
pub effect<'life0> fn readSome<'life0>(output: &'life0 mut [u8], deadline: silk/option.Option<silk/system_clock.Instant>) -> ReadTransfer ! ByteIoError ? &mut ByteDuplex | &mut MonotonicClockReads one positive prefix or reports orderly transport end.
Details
Empty output completes without calling the provider. An impossible provider count terminally
closes the lease and returns InvalidTransferCount, even if that close itself fails.
Associated function ByteDuplex.writeSome
pub effect<'life0> fn writeSome<'life0>(input: &'life0 [u8], deadline: silk/option.Option<silk/system_clock.Instant>) -> usize ! ByteIoError ? &mut ByteDuplex | &mut MonotonicClockWrites one positive prefix and returns its exact length.
Details
Empty input completes without calling the provider. An impossible provider count terminally
closes the lease and returns InvalidTransferCount, even if that close itself fails.
Associated function ByteDuplex.flush
pub effect<'static> fn flush(deadline: silk/option.Option<silk/system_clock.Instant>) -> () ! ByteIoError ? &mut ByteDuplex | &mut MonotonicClockFlushes accepted output to the provider's documented transport boundary.
Associated function ByteDuplex.shutdownWrite
pub effect<'static> fn shutdownWrite(deadline: silk/option.Option<silk/system_clock.Instant>) -> () ! ByteIoError ? &mut ByteDuplex | &mut MonotonicClockFlushes accepted output and then closes only the write direction.
Associated function ByteDuplex.close
pub effect<'static> fn close() -> () ! ByteIoError ? &mut ByteDuplexCloses the complete transport lease. Repeated calls remain terminal.
Associated function ByteDuplex.timeout
pub fn timeout(operation: ByteIoOperation) -> ByteIoErrorConstructs a timeout failure for operation.
Associated function ByteDuplex.invalidTransferCount
pub fn invalidTransferCount(operation: ByteIoOperation, count: usize, limit: usize) -> ByteIoErrorConstructs an invalid-count failure with the observed and permitted counts.
Associated function ByteDuplex.closed
pub fn closed(operation: ByteIoOperation) -> ByteIoErrorConstructs a closed-direction failure for operation.
Associated function ByteDuplex.provider
pub fn provider(operation: ByteIoOperation, code: i32) -> ByteIoErrorConstructs a provider failure with one provider-defined diagnostic code.