Dista · API

dista.seq

Seq[T]: a list that goes through the codec.

List can't be encoded by reflection, because reflection can't recover its element type. Seq[T] carries T as a parameter, so it can encode each element with the generic codec:

def total(xs: Seq[Int]) -> Int:
    var t = 0
    for i in range(len(xs)):
        t += xs[i]
    return t

comptime Total = Task[Seq[Int], Int, total]

On the wire a Seq is an 8-byte count, then each element's encoding. That is also how the runtime builds one from a list of ObjectRefs: the count, then each result's bytes as they arrived, without decoding them.

Structs

Seq

struct Seq[T: Copyable & Deinitable]

A list of T that tasks can take and return.

Implements Codec, Copyable, Movable, Sized

Fields
items: List[T]

__init__

def __init__(out self)
def __init__(out self, var items: List[T])

__getitem__

def __getitem__(self, i: Int) -> T

A copy of element i. Use items to borrow instead.

append

def append(mut self, var value: T)

__len__

def __len__(self) -> Int

encode

def encode(self, mut out: List[UInt8])

decode

def decode(buf: Span[UInt8], mut pos: Int) -> Self