Type

class dsviper.Type

Bases: object

The primitive types, and the utilities that act on any type.

Type.INT64, Type.STRING and the other scalars are read from here; the parameterized types are their own classes. Also encodes, decodes and sizes a type, and hashes it.

Note: Not directly instantiable.

ANY = any
ANY_CONCEPT = any_concept
BLOB = blob
BLOB_ID = blob_id
BOOL = bool
COMMIT_ID = commit_id
DOUBLE = double
FLOAT = float
INT16 = int16
INT32 = int32
INT64 = int64
INT8 = int8
STRING = string
UINT16 = uint16
UINT32 = uint32
UINT64 = uint64
UINT8 = uint8
UUID = uuid
VOID = void
static decode(blob: ValueBlob, definitions: DefinitionsConst, *, stream_codec_instancing: StreamCodecInstancing | None = None) → Type

Return a type by decoding the blob with Codec.STREAM_BINARY if not specified.

static encode(type: Type, *, stream_codec_instancing: StreamCodecInstancing | None = None) → ValueBlob

Return a blob that encodes the type with Codec.STREAM_BINARY if not specified.

static hexdigest(type: Type, *, hashing: Hashing | None = None) → str

Return the hexa digest of the type computed with the hashing interface if specified else use SHA1.

static is_sized(type: Type) → bool

Return True if the type has a fixed size and reads back alone.

A key is two uuids yet not sized: reading one back needs the definitions, which a pack-sized vector does not hold.

static read(stream_reading: StreamReading, definitions: DefinitionsConst) → Type

Read and return a type.

static size_of(type: Type, stream_sizing: StreamSizing) → int

Return the fixed size of the type or raise.

static use_blob_id(type: Type) → bool

Return True if the type uses the type blob_id.

static use_commit_id(type: Type) → bool

Return True if the type uses the type commit_id.

static write(type: Type, stream_writing: StreamWriting) → None

Write a type.