Skip to main content

Module mem

Module mem 

Source
Expand description

Built-in mem:// driver — in-memory synthetic byte buffers.

A process-global registry maps a string identifier to an Arc<Vec<u8>>; mem://<id> opens the buffer as a BytesSource. Useful for tests and for pipelines that want to feed pre-baked bytes through the same open(uri) shape they use for files.

The scheme has no on-wire spec — it is internal-to-OxideAV. Grammar (informal):

mem://<id>

where <id> is any byte sequence excluding /. Empty <id> is rejected (we want a non-ambiguous “default buffer” form to remain available for future use).

Functions§

clear
Drop every registered mem:// entry. Intended for test teardown.
open_mem
Open a mem://<id> URI as a BytesSource. Each open returns an independent reader over the same shared buffer — no per-open copy. Readers and seekers do not interfere with each other because each MemReader owns its own position, while the bytes themselves are reference-counted via Arc. Large mem:// buffers (e.g. pre-loaded test fixtures or in-memory transcode roundtrip targets) therefore cost a single Arc clone per open instead of a full Vec<u8> copy.
put
Install a buffer at mem://<id>. Replaces any prior entry under the same id. The buffer is held by reference; concurrent opens share it without copying.
remove
Remove an entry. Returns true if a buffer was present.