Skip to content

DelimitedRecord

Mojo struct 🡭

@memory_only
struct DelimitedRecord[MAX: Int = 64]

An owned, heap-allocated delimited row.

Created either directly (when ownership is needed from the start) or via DelimitedView.to_record(). Holds exactly one BString (the raw line bytes) and a stack-allocated FieldOffsets.

Field access via get_span() is zero-copy into the owned BString.

  • MAX (Int)

AnyType, Copyable, ImplicitlyDestructible, Movable, Sized, Writable

def __init__(out self)

Args:

  • self (Self)

Returns:

Self

def __init__(out self, var view: DelimitedView[view.O, MAX])

Materialize from a view — one BString alloc, offsets copied by value.

Args:

  • view (DelimitedView)
  • self (Self)

Returns:

Self

def __getitem__(ref self, idx: Int) -> BString

Owned copy of field idx. Prefer get_span() in hot paths.

Args:

  • self (Self)
  • idx (Int)

Returns:

BString

def num_fields(self) -> Int

Args:

  • self (Self)

Returns:

Int

def __len__(self) -> Int

Args:

  • self (Self)

Returns:

Int

def get_span(ref self, idx: Int) -> Span[UInt8, origin_of(self._line)]

Zero-copy view of field idx. Lifetime tied to this record.

Args:

  • self (Self)
  • idx (Int)

Returns:

Span

def get(ref self, idx: Int) -> Optional[BString]

Args:

  • self (Self)
  • idx (Int)

Returns:

Optional

def write_to[w: Writer](ref self, mut writer: w)

Parameters:

  • w (Writer)

Args:

  • self (Self)
  • writer (w)