OxL Reference

data View

view T ([С §9.6]): a lazily decoded, read-only view of an encoded T. Field access v.f decodes only the field f.

Example:

oxl✓ checked in CI
use std.ser { encode }
use std.core { decode_view }

data Person {
  id: i64
  name: str
}

fn main() io {
  let buf = encode(&Person{ id: 7, name: "ann" })!
  let v = decode_view<Person>(&buf)!
  print("{v.id} {v.name}")
}
Output
7 ann
@derive(Copy) pub(api) data View<T>

Thread safety. a borrow of the buffer; it must not outlive it or be sent to another task.

Since. 1.0.0-beta

Methods

own() -> T where T: Serializable
The whole value as an ordinary T (§9.6).
encoded() -> bytes
The encoded bytes the view reads (shared, not copied).

Defined in: std/core/view.oxl:33

See also