Skip to content

WriterBackend

Mojo trait 🡭

Trait for writing bytes to various backends.

Similar to Reader trait but for writing operations. Implementations provide write_from_buffer() to write bytes from a buffer to the underlying storage.

AnyType, ImplicitlyDestructible, Movable

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

Move constructor for Movable trait compliance.

Args:

  • take (_Self)
  • self (_Self)

Returns:

_Self

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

Write bytes from a buffer to the underlying storage.

Args:

  • self (_Self)
  • buf (Span): Source buffer containing bytes to write.
  • amt (Int): Number of bytes to write (must be <= len(buf) - pos).
  • pos (Int): Starting position in buf (default 0).

Returns:

UInt64: Number of bytes actually written.

Raises:

Error: If writing fails or parameters are invalid.