Silk

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 MemoryReadEvent

One scripted input event on an absolute monotonic timeline.

Data

MemoryReadEvent.Data { readyAt: Instant, bytes: Bytes }: MemoryReadEvent

Makes owned bytes available at readyAt and permits fragmentation by caller buffer size.

Field readyAt

pub readyAt: Instant

The event's absolute ready mark.

Field bytes

pub bytes: Bytes

The complete bytes released in order.

End

MemoryReadEvent.End { readyAt: Instant }: MemoryReadEvent

Reports orderly transport end at readyAt.

Field readyAt

pub readyAt: Instant

The event's absolute ready mark.

Failure

MemoryReadEvent.Failure { readyAt: Instant, code: i32 }: MemoryReadEvent

Reports one provider failure at readyAt.

Field readyAt

pub readyAt: Instant

The event's absolute ready mark.

Field code

pub code: i32

One provider-defined diagnostic code.

InvalidCount

MemoryReadEvent.InvalidCount { readyAt: Instant, count: usize }: MemoryReadEvent

Reports an impossible count to test lease validation.

Field readyAt

pub readyAt: Instant

The event's absolute ready mark.

Field count

pub count: usize

The impossible count returned without changing the output buffer.

MemoryWriteAction

pub union MemoryWriteAction

One scripted output action on an absolute monotonic timeline.

Accept

MemoryWriteAction.Accept { count: usize }: MemoryWriteAction

Accepts at most this positive prefix.

Field count

pub count: usize

The maximum accepted prefix.

Failure

MemoryWriteAction.Failure { code: i32 }: MemoryWriteAction

Reports one provider failure without accepting bytes.

Field code

pub code: i32

One provider-defined diagnostic code.

InvalidCount

MemoryWriteAction.InvalidCount { count: usize }: MemoryWriteAction

Reports an impossible count without accepting bytes.

Field count

pub count: usize

The impossible returned count.

MemoryWriteEvent

pub struct MemoryWriteEvent

One scripted output event on an absolute monotonic timeline.

Field readyAt

pub readyAt: Instant

The event's absolute ready mark.

Field action

pub action: MemoryWriteAction

The action performed when the event becomes ready.

MemoryByteDuplexPhase

pub enum MemoryByteDuplexPhase

The provider lifecycle phase visible to deterministic assertions.

Open

Open = 0

The complete lease and write direction remain active; input may still be readable or at end.

WriteShutdown

WriteShutdown = 1

The write direction is closed; input may still be readable or at end.

Closed

Closed = 2

The complete lease is terminal.

Invalid

Invalid = 3

An impossible transfer count invalidated the lease.

MemoryByteDuplexAudit

pub struct MemoryByteDuplexAudit

One operation recorded in provider order.

Field operation

pub operation: ByteIoOperation

The observed operation.

Field count

pub count: usize

The exact successful transfer prefix, or zero for lifecycle operations and failures.

Implementation Copy for MemoryWriteAction

impl Copy for MemoryWriteAction

Implementation Copy for MemoryByteDuplexAudit

impl Copy for MemoryByteDuplexAudit

MemoryByteDuplex

pub struct MemoryByteDuplex

A 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 Allocator

Constructs 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) -> MemoryByteDuplexPhase

Returns the current directional or terminal phase.

Method MemoryByteDuplex.closeAttempts

pub fn closeAttempts<'life0>(self: &'life0 MemoryByteDuplex) -> usize

Returns the number of first and repeated terminal close calls.

Implementation ByteDuplex for MemoryByteDuplex

impl ByteDuplex for MemoryByteDuplex

Operation readSomeRaw

readSomeRaw = MemoryByteDuplex.read

Operation writeSomeRaw

writeSomeRaw = MemoryByteDuplex.write

Operation flushRaw

flushRaw = MemoryByteDuplex.flushOutput

Operation shutdownWriteRaw

shutdownWriteRaw = MemoryByteDuplex.shutdownOutput

Operation closeRaw

closeRaw = MemoryByteDuplex.closeLease

On this page