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:
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}")
}Вывод
7 ann
@derive(Copy) pub(api) data View<T>Потокобезопасность. a borrow of the buffer; it must not outlive it or be sent to another task.
С версии. 1.0.0-beta
Методы
own | () -> T where T: SerializableThe whole value as an ordinary T (§9.6). |
encoded | () -> bytesThe encoded bytes the view reads (shared, not copied). |
Определено в: std/core/view.oxl:33