Skip to content

FileWriter

Mojo struct 🡭

@memory_only
struct FileWriter

Writer that writes to plain files.

Example:
```mojo
from blazeseq.io.buffered import buffered_writer_for_file
from std.pathlib import Path
from std.collections.string import String
var writer = buffered_writer_for_file(Path("out.fastq"))
var data = List(String("@read1

ACGT + IIII “).as_bytes()) writer.write_bytes(data) writer.flush() ```

  • handle (FileHandle)

AnyType, ImplicitlyDestructible, Movable, WriterBackend

def __init__(out self, path: Path)

Initialize FileWriter with a file path.

Args:

  • path (Path): Path to the output file.
  • self (Self)

Returns:

Self

Raises:

Error: If the file cannot be opened for writing.

def __init__(out self, *, deinit take: Self)

Move constructor.

Args:

  • take (Self)
  • self (Self)

Returns:

Self

def write_from_buffer(mut self, mut buf: Span[Byte, MutExternalOrigin], amt: Int, pos: Int = 0) -> UInt64

Write bytes from buffer to file.

Args:

  • self (Self)
  • buf (Span)
  • amt (Int)
  • pos (Int)

Returns:

UInt64

Raises: