Value

class dsviper.Value

Bases: object

A utility class to handle value instantiation and representation.

Note: Not directly instantiable.

static bson_decode(blob: ValueBlob, type_structure: TypeStructure, definitions: DefinitionsConst) ValueStructure

Return a value by decoding the bson encoded blob of a structure.

static bson_encode(value: ValueStructure) ValueBlob

Return the bson encoded blob of the value.

static collect_blob_ids(object: Value) set[ValueBlobId]

Return the set of blob_id of all referenced blob_id by the object, where object must be a Value, a Path, a CommitState, a CommitMutableState or a ValueProgram.

static copy(value: Value) Value

Return a copy of a value (deepcopy).

static decode(blob: ValueBlob, type: Type, definitions: DefinitionsConst, *, stream_codec_instancing: StreamCodecInstancing | None = None, pack_sized: bool = False) Value

Return a Value by decoding the blob with a StreamBinaryCodec if not specified.

If pack_sized is True, then the vector<T> where T is a Sized type keeps an element in the binary encoded representation. This feature is only used for decoding huge immutable resource by deferred the decoding cost to the method ValueVector.at(index).

static deduce(value: _PythonValues) Value

Return a strong typed conversion of a Python object.

static dumps(value: Value, *, json: bool = False) _PythonValues

Return a projection to Python objects of the strong typed value. If json is True then: - a set is converted to a list. - a map is converted to a list of (key, value).

static encode(value: Value, *, stream_codec_instancing: StreamCodecInstancing | None = None) ValueBlob

Return a blob that encodes the value with a StreamBinaryCodec if not specified.

static hexdigest(value: Value, *, hashing: Hashing | None = None) str

Hash the value with the hashing interface if specified else use SHA1.

static json_decode(string: str, type: Type, definitions: DefinitionsConst) Value

Return a value by decoding the json encoded string.

static json_encode(value: Value, indent: int = -1) str

Return the JSON encoded string for the value.

static loads(object: _PythonValues, type: Type, definitions: DefinitionsConst) Value

Return a value by decoding the Python object.

static read(type: Type, stream_reading: StreamReading, definitions: DefinitionsConst, *, pack_sized: bool = False) Value

Read the value from the stream.

static succ(value: Value) Value

Return the successor of a value.

static write(value: Value, stream_writing: StreamWriting) None

Write the value to the stream.