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, Deinitable, Movable, WriterBackend
Methods
Section titled “Methods”__init__
Section titled “__init__”fn 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.
fn def __init__(out self, *, deinit move: Self)Move constructor.
Args:
- move (
Self) - self (
Self)
Returns:
Self
write_from_buffer
Section titled “write_from_buffer”fn def write_from_buffer(mut self, mut buf: Span[UInt8, MutUntrackedOrigin], amt: Int, pos: Int = Int(0)) -> UInt64Write bytes from buffer to file.
Args:
- self (
Self) - buf (
Span[UInt8, MutUntrackedOrigin]) - amt (
Int) - pos (
Int)
Returns:
UInt64
Raises: