MappedFile
Mojo struct 🡭
MappedFile
Section titled “MappedFile”@memory_onlystruct MappedFileRead-only memory map of a file.
Example:
var mapped = MappedFile(Path("data.fastq"))var view = mapped.view() # Span[Byte] over the whole fileThe mapping lives for the lifetime of the struct; __deinit__ unmaps and
closes the descriptor. Keep the struct alive while any view into it is
used — views do not extend the mapping’s lifetime.
Implemented traits
Section titled “Implemented traits”AnyType, Deinitable, Movable
Methods
Section titled “Methods”__init__
Section titled “__init__”fn def __init__(out self, path: Path)Args:
- path (
Path) - self (
Self)
Returns:
Self
Raises:
fn def __init__(out self, *, deinit move: Self)Args:
- move (
Self) - self (
Self)
Returns:
Self
__deinit__
Section titled “__deinit__”fn def __deinit__(deinit self)Args:
- self (
Self)
fn def size(self) -> IntArgs:
- self (
Self)
Returns:
Int
fn def view(self) -> Span[UInt8, MutUntrackedOrigin]Whole-file byte span. Empty file yields a zero-length span.
Args:
- self (
Self)
Returns:
Span[UInt8, MutUntrackedOrigin]