MemoryReader
Mojo struct 🡭
MemoryReader
Section titled “MemoryReader”@memory_onlystruct MemoryReaderReader that reads from an in-memory buffer.
Use for testing, benchmarking (without disk I/O), or when FASTQ data is already in memory. Implements the same Reader trait as FileReader and GZFile.
Fields
Section titled “Fields”- data (
List[Byte]) - position (
Int)
Implemented traits
Section titled “Implemented traits”AnyType, ImplicitlyDestructible, Movable, Reader
Methods
Section titled “Methods”__init__
Section titled “__init__”def __init__(out self, var data: List[Byte])Initialize with an owned List[Byte] buffer. Takes ownership of data.
Args:
- data (
List) - self (
Self)
Returns:
Self
def __init__(out self, data: Span[Byte, data.origin])Initialize with a Span[Byte]; bytes are copied into an internal list.
Args:
- data (
Span) - self (
Self)
Returns:
Self
def __init__(out self, var content: String)Initialize from a string; copies its bytes into an internal buffer.
Args:
- content (
String) - self (
Self)
Returns:
Self
Raises:
def __init__(out self, *, deinit take: Self)Move constructor for Movable trait compliance.
Args:
- take (
Self) - self (
Self)
Returns:
Self
read_to_buffer
Section titled “read_to_buffer”def read_to_buffer(mut self, mut buf: Span[Byte, MutExternalOrigin], amt: Int, pos: Int = 0) -> UInt64Read bytes from the memory buffer into the destination buffer.
Args:
- self (
Self) - buf (
Span): The destination buffer to write into. - amt (
Int): The number of bytes to read. - pos (
Int): The position in the destination buffer to start writing.
Returns:
UInt64: The number of bytes actually read (0 if EOF).
Raises:
def reset(mut self)Reset the read position to the start. Use to re-read the same buffer (e.g. for benchmarking).
Args:
- self (
Self)