silk/memory_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.
A bounded scripted in-memory ByteDuplex provider for deterministic protocol execution.
When to use
Use MemoryByteDuplex to drive exact transport fragments, deadlines, end, and failures
without a socket. Supply it lexically as silk.byte_duplex.ByteDuplex.
Details
Construction owns all script, output, and audit storage. Service operations allocate nothing.
Event times and operation deadlines use the active MonotonicClock timeline. The provider
records accepted byte prefixes and lifecycle order for later inspection. Once input reports
End, later reads remain at end without consulting another script event.
Gotchas
This provider models reliable bytes only. It does not model packets, network policy, DNS, or host trust. When an event time equals a deadline, the deadline wins.
Import as MemoryByteDuplex with import silk.memory_byte_duplex { MemoryByteDuplex }.
Public declarations: 6.
MemoryReadEvent
pub union MemoryReadEventOne scripted input event on an absolute monotonic timeline.
Data
MemoryReadEvent.Data { readyAt: Instant, bytes: Bytes }: MemoryReadEventMakes owned bytes available at readyAt and permits fragmentation by caller buffer size.
Field readyAt
pub readyAt: InstantThe event's absolute ready mark.
Field bytes
pub bytes: BytesThe complete bytes released in order.
End
MemoryReadEvent.End { readyAt: Instant }: MemoryReadEventReports orderly transport end at readyAt.
Field readyAt
pub readyAt: InstantThe event's absolute ready mark.
Failure
MemoryReadEvent.Failure { readyAt: Instant, code: i32 }: MemoryReadEventReports one provider failure at readyAt.
Field readyAt
pub readyAt: InstantThe event's absolute ready mark.
Field code
pub code: i32One provider-defined diagnostic code.
InvalidCount
MemoryReadEvent.InvalidCount { readyAt: Instant, count: usize }: MemoryReadEventReports an impossible count to test lease validation.
Field readyAt
pub readyAt: InstantThe event's absolute ready mark.
Field count
pub count: usizeThe impossible count returned without changing the output buffer.
MemoryWriteAction
pub union MemoryWriteActionOne scripted output action on an absolute monotonic timeline.
Accept
MemoryWriteAction.Accept { count: usize }: MemoryWriteActionAccepts at most this positive prefix.
Field count
pub count: usizeThe maximum accepted prefix.
Failure
MemoryWriteAction.Failure { code: i32 }: MemoryWriteActionReports one provider failure without accepting bytes.
Field code
pub code: i32One provider-defined diagnostic code.
InvalidCount
MemoryWriteAction.InvalidCount { count: usize }: MemoryWriteActionReports an impossible count without accepting bytes.
Field count
pub count: usizeThe impossible returned count.
MemoryWriteEvent
pub struct MemoryWriteEventOne scripted output event on an absolute monotonic timeline.
Field readyAt
pub readyAt: InstantThe event's absolute ready mark.
Field action
pub action: MemoryWriteActionThe action performed when the event becomes ready.
MemoryByteDuplexPhase
pub enum MemoryByteDuplexPhaseThe provider lifecycle phase visible to deterministic assertions.
Open
Open = 0The complete lease and write direction remain active; input may still be readable or at end.
WriteShutdown
WriteShutdown = 1The write direction is closed; input may still be readable or at end.
Closed
Closed = 2The complete lease is terminal.
Invalid
Invalid = 3An impossible transfer count invalidated the lease.
MemoryByteDuplexAudit
pub struct MemoryByteDuplexAuditOne operation recorded in provider order.
Field operation
pub operation: ByteIoOperationThe observed operation.
Field count
pub count: usizeThe exact successful transfer prefix, or zero for lifecycle operations and failures.
Implementation Copy for MemoryWriteAction
impl Copy for MemoryWriteActionImplementation Copy for MemoryByteDuplexAudit
impl Copy for MemoryByteDuplexAuditMemoryByteDuplex
pub struct MemoryByteDuplexA bounded scripted provider with owned input, output, and audit storage.
Associated function MemoryByteDuplex.make
pub effect<'static> fn make(reads: silk/vector.Vector<silk/memory_byte_duplex.MemoryReadEvent>, writes: silk/vector.Vector<silk/memory_byte_duplex.MemoryWriteEvent>, outboundCapacity: usize, auditCapacity: usize, closeFailure: silk/option.Option<i32>) -> MemoryByteDuplex ! OutOfMemoryError ? &mut AllocatorConstructs a bounded provider and preallocates every byte and audit slot used by operations.
Method MemoryByteDuplex.outbound
pub fn outbound<'a>(self: &'a MemoryByteDuplex) -> &'a [u8]Returns the exact accepted output prefix in write order.
Method MemoryByteDuplex.audit
pub fn audit<'a>(self: &'a MemoryByteDuplex) -> &'a [silk/memory_byte_duplex.MemoryByteDuplexAudit]Returns the initialized audit prefix in operation order.
Method MemoryByteDuplex.phase
pub fn phase<'life0>(self: &'life0 MemoryByteDuplex) -> MemoryByteDuplexPhaseReturns the current directional or terminal phase.
Method MemoryByteDuplex.closeAttempts
pub fn closeAttempts<'life0>(self: &'life0 MemoryByteDuplex) -> usizeReturns the number of first and repeated terminal close calls.
Implementation ByteDuplex for MemoryByteDuplex
impl ByteDuplex for MemoryByteDuplexOperation readSomeRaw
readSomeRaw = MemoryByteDuplex.readOperation writeSomeRaw
writeSomeRaw = MemoryByteDuplex.writeOperation flushRaw
flushRaw = MemoryByteDuplex.flushOutputOperation shutdownWriteRaw
shutdownWriteRaw = MemoryByteDuplex.shutdownOutputOperation closeRaw
closeRaw = MemoryByteDuplex.closeLease