GZWriter
Mojo struct 🡭
GZWriter
Section titled “GZWriter”@memory_onlystruct GZWriterWriter for gzip-compressed files.
Fields
Section titled “Fields”- handle (
c_void_ptr) - lib (
ZLib) - filename (
String) - mode (
String)
Implemented traits
Section titled “Implemented traits”AnyType, ImplicitlyDestructible, Movable, WriterBackend
Methods
Section titled “Methods”__init__
Section titled “__init__”def __init__(out self, filename: String, mode: String = "wb")Initialize GZWriter with a file path.
Args:
- filename (
String): Path to the output .gz file. - mode (
String): File mode (default “wb” for write binary). - 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
__del__
Section titled “__del__”def __del__(deinit self)Close the file when the object is destroyed.
Args:
- self (
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 compressed file.
Args:
- self (
Self) - buf (
Span) - amt (
Int) - pos (
Int)
Returns:
UInt64
Raises: