A host-managed immutable byte buffer. Buffers exist in host memory, not in component linear memory. Components interact with buffers through opaque handles.
Method
Signature
Ownership
Description
size
func() -> u64
Read-only (borrow)
Returns the byte length of the buffer contents.
content-type
func() -> string
Read-only (borrow)
Returns a content-type hint (e.g., "application/json"). Empty string if unset.
read
func(offset: u64, len: u64) -> list<u8>
Read-only (borrow). Triggers a measured copy from host to component memory.
Read up to len bytes starting at offset. Returns fewer bytes if buffer is shorter than offset+len.
read-all
func() -> list<u8>
Read-only (borrow). Triggers a measured copy.
Read the entire buffer contents. Equivalent to read(0, self.size()).
Performance note:read and read-all copy data from host memory into component linear memory. The resource manager records this as a PayloadRead copy event. Components that only need metadata should use size() and content-type() instead.
Pull the next element. ok(some(element)): data available. ok(none): source exhausted. err(error): production error. Output buffer is owned by the runtime.
notify-backpressure
func(signal: backpressure-signal)
Receive a backpressure signal from the downstream pipeline. Called by the runtime between pull() invocations.
Push an element into the sink. Returns ready (accept more) or pause (slow down). Input is borrowed — sink must copy payload bytes during this call if it needs to buffer them.
complete
func() -> result<_, process-error>
Signal that no more elements will arrive. Sink should flush any buffered data.
Optional. Exported by components that need initialization or cleanup.
Function
Signature
Description
init
func(config: string) -> result<_, process-error>
Called once after instantiation, before stream processing. Configuration string is component-specific (JSON recommended). Error prevents pipeline startup.
teardown
func()
Called once during shutdown. Best-effort — the runtime may skip this on forced termination.