FileWriter
Mojo struct 🡭
FileWriter
Section titled “FileWriter”@memory_onlystruct FileWriterWriter 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("@read1ACGT + IIII “).as_bytes()) writer.write_bytes(data) writer.flush() ```
Fields
Section titled “Fields”- handle (
FileHandle)
Implemented traits
Section titled “Implemented traits”AnyType, ImplicitlyDestructible, Movable, WriterBackend
Methods
Section titled “Methods”__init__
Section titled “__init__”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
write_from_buffer
Section titled “write_from_buffer”def write_from_buffer(mut self, mut buf: Span[Byte, MutExternalOrigin], amt: Int, pos: Int = 0) -> UInt64Write bytes from buffer to file.
Args:
- self (
Self) - buf (
Span) - amt (
Int) - pos (
Int)
Returns:
UInt64
Raises: