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, Deinitable, Movable

fn def __init__(out self, *, deinit move: Self)

Move constructor for Movable trait compliance.

Args:

  • move (_Self)
  • self (_Self)

Returns:

_Self

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

Write bytes from a buffer to the underlying storage.

Args:

  • self (_Self)
  • buf (Span[UInt8, MutUntrackedOrigin]): 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.