runtimepy.primitives package#
Subpackages#
- runtimepy.primitives.array package
- Module contents
ArrayFragmentSpecPrimitiveArrayPrimitiveArray.add()PrimitiveArray.add_primitive()PrimitiveArray.byte_at_index()PrimitiveArray.fragment()PrimitiveArray.fragment_bytes()PrimitiveArray.fragment_from_byte_indices()PrimitiveArray.fragment_from_indices()PrimitiveArray.index_at_byte()PrimitiveArray.num_fragmentsPrimitiveArray.reset()PrimitiveArray.update()PrimitiveArray.update_fragment()
- Module contents
- runtimepy.primitives.field package
- runtimepy.primitives.serializable package
- runtimepy.primitives.types package
- Submodules
- runtimepy.primitives.types.base module
- runtimepy.primitives.types.bool module
- runtimepy.primitives.types.bounds module
- runtimepy.primitives.types.float module
- runtimepy.primitives.types.int module
- Module contents
Submodules#
runtimepy.primitives.base module#
A module implementing a base, primitive-type storage entity.
- class runtimepy.primitives.base.Primitive(value: T = None, scaling: list[float | int] = None)[source]#
Bases:
Generic[T]A simple class for storing and underlying primitive value.
- classmethod decode(data: bytes, byte_order: ByteOrder = None) T[source]#
Decode a primitive of this type from provided data.
- classmethod encode(value: T, byte_order: ByteOrder = None) bytes[source]#
Create a bytes instance based on this primitive type.
- from_stream(stream: BinaryIO, byte_order: ByteOrder = None) T[source]#
Update this primitive from a stream and return the new value.
- kind: Int8Type | Int16Type | Int32Type | Int64Type | Uint8Type | Uint16Type | Uint32Type | Uint64Type | HalfType | FloatType | DoubleType | BooleanType#
- classmethod read(stream: BinaryIO, byte_order: ByteOrder = None) T[source]#
Read a primitive from the provided stream based on this primitive type.
- register_callback(callback: Callable[[T, T], None], once: bool = False) int[source]#
Register a callback and return an identifier for it.
- remove_callback(callback_id: int) bool[source]#
Remove a callback if one is registered with this identifier.
- property scaled: float | int#
Get this primitive as a scaled value.
- property size: int#
Get the size of this primitive.
- to_stream(stream: BinaryIO, byte_order: ByteOrder = None) int[source]#
Write this primitive to a stream.
- update(data: bytes, byte_order: ByteOrder = None) T[source]#
Update this primitive from a bytes object.
- property value: T#
Obtain the underlying value.
runtimepy.primitives.bool module#
A module implementing a boolean-primitive interface.
- runtimepy.primitives.bool.Bool#
alias of
BooleanPrimitive
runtimepy.primitives.byte_order module#
A module implementing an enumeration for byte ordering options.
- class runtimepy.primitives.byte_order.ByteOrder(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Bases:
RuntimeIntEnumAn enumeration for viable byte orders.
- BIG_ENDIAN = 3#
- LITTLE_ENDIAN = 2#
- NATIVE = 1#
- NETWORK = 4#
- property fmt: str#
Get the struct formatter for this byte order.
runtimepy.primitives.float module#
A module implementing a floating-point primitive interface.
- runtimepy.primitives.float.Double#
alias of
DoublePrimitive
- class runtimepy.primitives.float.DoublePrimitive(value: float = 0.0, scaling: list[float | int] = None)[source]#
Bases:
Primitive[float]A simple primitive class for double-precision floating-point.
- kind: _AnyPrimitiveType = <runtimepy.primitives.types.float.DoubleType object>#
- runtimepy.primitives.float.Float#
alias of
FloatPrimitive
- class runtimepy.primitives.float.FloatPrimitive(value: float = 0.0, scaling: list[float | int] = None)[source]#
Bases:
Primitive[float]A simple primitive class for single-precision floating-point.
- kind: _AnyPrimitiveType = <runtimepy.primitives.types.float.FloatType object>#
- runtimepy.primitives.float.Half#
alias of
HalfPrimitive
runtimepy.primitives.int module#
A module implementing an integer-primitive interface.
- runtimepy.primitives.int.Int16#
alias of
Int16Primitive
- class runtimepy.primitives.int.Int16Primitive(value: int = 0, scaling: list[float | int] = None)[source]#
Bases:
Primitive[int]A simple primitive class for integer primitives.
- kind: _AnyPrimitiveType = <runtimepy.primitives.types.int.Int16Type object>#
- runtimepy.primitives.int.Int32#
alias of
Int32Primitive
- class runtimepy.primitives.int.Int32Primitive(value: int = 0, scaling: list[float | int] = None)[source]#
Bases:
Primitive[int]A simple primitive class for integer primitives.
- kind: _AnyPrimitiveType = <runtimepy.primitives.types.int.Int32Type object>#
- runtimepy.primitives.int.Int64#
alias of
Int64Primitive
- class runtimepy.primitives.int.Int64Primitive(value: int = 0, scaling: list[float | int] = None)[source]#
Bases:
Primitive[int]A simple primitive class for integer primitives.
- kind: _AnyPrimitiveType = <runtimepy.primitives.types.int.Int64Type object>#
- runtimepy.primitives.int.Int8#
alias of
Int8Primitive
- class runtimepy.primitives.int.Int8Primitive(value: int = 0, scaling: list[float | int] = None)[source]#
Bases:
Primitive[int]A simple primitive class for integer primitives.
- kind: _AnyPrimitiveType = <runtimepy.primitives.types.int.Int8Type object>#
- runtimepy.primitives.int.Uint16#
alias of
Uint16Primitive
- class runtimepy.primitives.int.Uint16Primitive(value: int = 0, scaling: list[float | int] = None)[source]#
Bases:
Primitive[int]A simple primitive class for integer primitives.
- kind: _AnyPrimitiveType = <runtimepy.primitives.types.int.Uint16Type object>#
- runtimepy.primitives.int.Uint32#
alias of
Uint32Primitive
- class runtimepy.primitives.int.Uint32Primitive(value: int = 0, scaling: list[float | int] = None)[source]#
Bases:
Primitive[int]A simple primitive class for integer primitives.
- kind: _AnyPrimitiveType = <runtimepy.primitives.types.int.Uint32Type object>#
- runtimepy.primitives.int.Uint64#
alias of
Uint64Primitive
- class runtimepy.primitives.int.Uint64Primitive(value: int = 0, scaling: list[float | int] = None)[source]#
Bases:
Primitive[int]A simple primitive class for integer primitives.
- kind: _AnyPrimitiveType = <runtimepy.primitives.types.int.Uint64Type object>#
- runtimepy.primitives.int.Uint8#
alias of
Uint8Primitive
runtimepy.primitives.scaling module#
A module implementing interfaces for working with channel scaling polynomials.
runtimepy.primitives.string module#
A module implementing integer-prefixed string reading and writing.
- class runtimepy.primitives.string.StringPrimitive(value: str = '', kind: type[~runtimepy.primitives.base.Primitive[int]] = <class 'runtimepy.primitives.int.Uint16Primitive'>, byte_order: ~runtimepy.primitives.byte_order.ByteOrder = ByteOrder.NETWORK)[source]#
Bases:
objectA class implementing a string-primitive interface.
- static from_stream(stream: ~typing.BinaryIO, kind: type[~runtimepy.primitives.base.Primitive[int]] = <class 'runtimepy.primitives.int.Uint16Primitive'>, byte_order: ~runtimepy.primitives.byte_order.ByteOrder = ByteOrder.NETWORK) StringPrimitive[source]#
Create a new string primitive from a stream.
- property size: int#
Get the overall size of this string primitive.
- property value: str#
Get the value of this string.
Module contents#
A module implementing a primitive-type storage entity.
- runtimepy.primitives.Bool#
alias of
BooleanPrimitive
- runtimepy.primitives.Double#
alias of
DoublePrimitive
- runtimepy.primitives.Float#
alias of
FloatPrimitive
- runtimepy.primitives.Half#
alias of
HalfPrimitive
- runtimepy.primitives.Int16#
alias of
Int16Primitive
- runtimepy.primitives.Int32#
alias of
Int32Primitive
- runtimepy.primitives.Int64#
alias of
Int64Primitive
- runtimepy.primitives.Int8#
alias of
Int8Primitive
- class runtimepy.primitives.Primitive(value: T = None, scaling: list[float | int] = None)[source]#
Bases:
Generic[T]A simple class for storing and underlying primitive value.
- callbacks: dict[int, tuple[Callable[[T, T], None], bool]]#
- curr_callback: int#
- classmethod decode(data: bytes, byte_order: ByteOrder = None) T[source]#
Decode a primitive of this type from provided data.
- classmethod encode(value: T, byte_order: ByteOrder = None) bytes[source]#
Create a bytes instance based on this primitive type.
- from_stream(stream: BinaryIO, byte_order: ByteOrder = None) T[source]#
Update this primitive from a stream and return the new value.
- kind: Int8Type | Int16Type | Int32Type | Int64Type | Uint8Type | Uint16Type | Uint32Type | Uint64Type | HalfType | FloatType | DoubleType | BooleanType#
- last_updated_ns: int#
- classmethod read(stream: BinaryIO, byte_order: ByteOrder = None) T[source]#
Read a primitive from the provided stream based on this primitive type.
- register_callback(callback: Callable[[T, T], None], once: bool = False) int[source]#
Register a callback and return an identifier for it.
- remove_callback(callback_id: int) bool[source]#
Remove a callback if one is registered with this identifier.
- property scaled: float | int#
Get this primitive as a scaled value.
- property size: int#
Get the size of this primitive.
- to_stream(stream: BinaryIO, byte_order: ByteOrder = None) int[source]#
Write this primitive to a stream.
- update(data: bytes, byte_order: ByteOrder = None) T[source]#
Update this primitive from a bytes object.
- property value: T#
Obtain the underlying value.
- class runtimepy.primitives.StrToBool(result: bool, valid: bool)[source]#
Bases:
NamedTupleA container for results when converting strings to boolean.
- result: bool#
Alias for field number 0
- valid: bool#
Alias for field number 1
- runtimepy.primitives.Uint16#
alias of
Uint16Primitive
- runtimepy.primitives.Uint32#
alias of
Uint32Primitive
- runtimepy.primitives.Uint64#
alias of
Uint64Primitive
- runtimepy.primitives.Uint8#
alias of
Uint8Primitive
- runtimepy.primitives.create(value: type[Int8Primitive | Int16Primitive | Int32Primitive | Int64Primitive | Uint8Primitive | Uint16Primitive | Uint32Primitive | Uint64Primitive | HalfPrimitive | FloatPrimitive | DoublePrimitive | BooleanPrimitive] | str, **kwargs) Int8Primitive | Int16Primitive | Int32Primitive | Int64Primitive | Uint8Primitive | Uint16Primitive | Uint32Primitive | Uint64Primitive | HalfPrimitive | FloatPrimitive | DoublePrimitive | BooleanPrimitive[source]#
Create an instance of a primitive.
- runtimepy.primitives.normalize(value: type[Int8Primitive | Int16Primitive | Int32Primitive | Int64Primitive | Uint8Primitive | Uint16Primitive | Uint32Primitive | Uint64Primitive | HalfPrimitive | FloatPrimitive | DoublePrimitive | BooleanPrimitive] | str) type[Int8Primitive | Int16Primitive | Int32Primitive | Int64Primitive | Uint8Primitive | Uint16Primitive | Uint32Primitive | Uint64Primitive | HalfPrimitive | FloatPrimitive | DoublePrimitive | BooleanPrimitive][source]#
Normalize a type of primitive or a string into a type of primitive.