Skip to main content

Crate ostrya_gvariant

Crate ostrya_gvariant 

Source
Expand description

A byte-exact GVariant codec for the ostree on-disk format.

A caller writes values as GVariant bytes in normal form and reads them back. The checksum of each ostree metadata object is the hash of these bytes, so each metadata checksum of ostrya depends on this crate. The typed codec reads fields in place with no allocation. The crate has no ostree knowledge.

§Entry points

§Examples

use ostrya_gvariant::{Type, Value, from_bytes, to_bytes};

let ty = Type::parse("(su)")?;
let value = Value::Tuple(vec![Value::from("ostree"), Value::from(7u32)]);
let bytes = to_bytes(&ty, &value)?;
// The string, one padding byte, the `u`, and the framing offset 7.
assert_eq!(bytes, b"ostree\0\0\x07\0\0\0\x07");
assert_eq!(from_bytes(&ty, &bytes)?, value);

Structs§

ArrayIter
A lazy iterator over the elements of a serialized array.
DictBuilder
A builder for an a{sv} dict value.
ElementType
A type in a container type: the element of a maybe or of an array, or the key or the value of a dict entry.
MemberTypes
The member types of a tuple type, in order.
Slice
An array to encode from a Rust slice of encodable elements.
Span
A half-open byte range of the input text that a TextError names.
TextError
The error for a GVariant text form that from_text refuses.
Variant
A decoded variant that holds the type and the value of its child.
VariantBytes
A variant read in place, as borrowed child bytes and signature.

Enums§

Error
An error of the GVariant codec.
Type
A GVariant type.
Value
A dynamically typed GVariant value.

Traits§

GvDecode
A type that reads itself from normal-form GVariant bytes.
GvEncode
A type that writes itself as normal-form GVariant bytes.
GvType
The type-level facts of a type that encodes as GVariant.

Functions§

choose_offset_size
Returns the size in bytes of each framing offset of a container.
encode_to_vec
Encodes a top-level value into a new byte vector.
from_bytes
Deserializes normal-form GVariant bytes of type ty into a Value.
from_text
Reads one GVariant text form and returns the type it states and the value.
offset_size_for
Returns the framing-offset size for a container of len serialized bytes.
to_bytes
Serializes value as type ty in GVariant normal form.
to_text
Renders value of type ty in the GVariant text form.
to_text_unannotated
Renders value of type ty in the GVariant text form with no annotations.
tuple_field_from_bytes
Deserializes one member of a serialized tuple into a Value.
validate
Checks that data is normal-form GVariant bytes of type ty.
write_array
Appends n array elements with normal-form framing to out.
write_offset
Appends one framing offset of width z.

Type Aliases§

Result
The result type of the codec.