runtimepy.codec.protocol.base
index
/home/vkottler/src/vkottler/workspace/runtimepy/runtimepy/codec/protocol/base.py

A module implementing an interface to build communication protocols.

 
Classes
       
builtins.object
ProtocolBase
builtins.tuple(builtins.object)
FieldSpec

 
class FieldSpec(builtins.tuple)
    FieldSpec(name: str, kind: Union[type[Union[runtimepy.primitives.int.Int8Primitive, runtimepy.primitives.int.Int16Primitive, runtimepy.primitives.int.Int32Primitive, runtimepy.primitives.int.Int64Primitive, runtimepy.primitives.int.Uint8Primitive, runtimepy.primitives.int.Uint16Primitive, runtimepy.primitives.int.Uint32Primitive, runtimepy.primitives.int.Uint64Primitive, runtimepy.primitives.float.HalfPrimitive, runtimepy.primitives.float.FloatPrimitive, runtimepy.primitives.float.DoublePrimitive, runtimepy.primitives.bool.BooleanPrimitive]], str], enum: Union[str, int, NoneType] = None, array_length: Optional[int] = None)
 
Information specifying a protocol field.
 
 
Method resolution order:
FieldSpec
builtins.tuple
builtins.object

Methods defined here:
__getnewargs__(self)
Return self as a plain tuple.  Used by copy and pickle.
__repr__(self)
Return a nicely formatted representation string
_asdict(self)
Return a new dict which maps field names to their values.
_replace(self, /, **kwds)
Return a new FieldSpec object replacing specified fields with new values
asdict(self) -> Dict[str, Union[str, int, float, bool, NoneType, Dict[str, Union[str, int, float, bool, NoneType]], List[Union[str, int, float, bool, NoneType]]]]
Obtain a dictionary representing this instance.

Class methods defined here:
_make(iterable) from builtins.type
Make a new FieldSpec object from a sequence or iterable

Static methods defined here:
__new__(_cls, name: str, kind: Union[type[Union[runtimepy.primitives.int.Int8Primitive, runtimepy.primitives.int.Int16Primitive, runtimepy.primitives.int.Int32Primitive, runtimepy.primitives.int.Int64Primitive, runtimepy.primitives.int.Uint8Primitive, runtimepy.primitives.int.Uint16Primitive, runtimepy.primitives.int.Uint32Primitive, runtimepy.primitives.int.Uint64Primitive, runtimepy.primitives.float.HalfPrimitive, runtimepy.primitives.float.FloatPrimitive, runtimepy.primitives.float.DoublePrimitive, runtimepy.primitives.bool.BooleanPrimitive]], str], enum: Union[str, int, NoneType] = None, array_length: Optional[int] = None)
Create new instance of FieldSpec(name, kind, enum, array_length)

Data descriptors defined here:
name
Alias for field number 0
kind
Alias for field number 1
enum
Alias for field number 2
array_length
Alias for field number 3

Data and other attributes defined here:
__annotations__ = {'array_length': typing.Optional[int], 'enum': typing.Union[str, int, NoneType], 'kind': typing.Union[type[typing.Union[runtimepy.primiti...untimepy.primitives.bool.BooleanPrimitive]], str], 'name': <class 'str'>}
__match_args__ = ('name', 'kind', 'enum', 'array_length')
__orig_bases__ = (<function NamedTuple>,)
_field_defaults = {'array_length': None, 'enum': None}
_fields = ('name', 'kind', 'enum', 'array_length')

Methods inherited from builtins.tuple:
__add__(self, value, /)
Return self+value.
__contains__(self, key, /)
Return bool(key in self).
__eq__(self, value, /)
Return self==value.
__ge__(self, value, /)
Return self>=value.
__getattribute__(self, name, /)
Return getattr(self, name).
__getitem__(self, key, /)
Return self[key].
__gt__(self, value, /)
Return self>value.
__hash__(self, /)
Return hash(self).
__iter__(self, /)
Implement iter(self).
__le__(self, value, /)
Return self<=value.
__len__(self, /)
Return len(self).
__lt__(self, value, /)
Return self<value.
__mul__(self, value, /)
Return self*value.
__ne__(self, value, /)
Return self!=value.
__rmul__(self, value, /)
Return value*self.
count(self, value, /)
Return number of occurrences of value.
index(self, value, start=0, stop=9223372036854775807, /)
Return first index of value.
 
Raises ValueError if the value is not present.

Class methods inherited from builtins.tuple:
__class_getitem__(...) from builtins.type
See PEP 585

 
class ProtocolBase(builtins.object)
    ProtocolBase(enum_registry: runtimepy.enum.registry.EnumRegistry, names: runtimepy.registry.name.NameRegistry = None, fields: runtimepy.primitives.field.manager.BitFieldsManager = None, build: list[typing.Union[int, runtimepy.codec.protocol.base.FieldSpec, str]] = None, identifier: int = 1, byte_order: Union[runtimepy.primitives.byte_order.ByteOrder, str, int] = &lt;ByteOrder.NETWORK: 4&gt;, serializables: dict[str, runtimepy.primitives.serializable.base.Serializable] = None) -&gt; None
 
A class for defining runtime communication protocols.
 
  Methods defined here:
__copy__(self: ~T) -> ~T
Create another protocol instance from this one.
__getitem__(self, name: str) -> Union[int, float, bool, str]
Get the value of a protocol field.
__init__(self, enum_registry: runtimepy.enum.registry.EnumRegistry, names: runtimepy.registry.name.NameRegistry = None, fields: runtimepy.primitives.field.manager.BitFieldsManager = None, build: list[typing.Union[int, runtimepy.codec.protocol.base.FieldSpec, str]] = None, identifier: int = 1, byte_order: Union[runtimepy.primitives.byte_order.ByteOrder, str, int] = <ByteOrder.NETWORK: 4>, serializables: dict[str, runtimepy.primitives.serializable.base.Serializable] = None) -> None
Initialize this protocol.
__setitem__(self, name: str, val: Union[int, float, bool, str]) -> None
Set a value of a field belonging to the protocol.
__str__(self) -> str
Get this instance as a string.
add_bit_fields(self, kind: Union[type[Union[runtimepy.primitives.int.Int8Primitive, runtimepy.primitives.int.Int16Primitive, runtimepy.primitives.int.Int32Primitive, runtimepy.primitives.int.Int64Primitive, runtimepy.primitives.int.Uint8Primitive, runtimepy.primitives.int.Uint16Primitive, runtimepy.primitives.int.Uint32Primitive, runtimepy.primitives.int.Uint64Primitive, runtimepy.primitives.float.HalfPrimitive, runtimepy.primitives.float.FloatPrimitive, runtimepy.primitives.float.DoublePrimitive, runtimepy.primitives.bool.BooleanPrimitive]], str] = 'uint8') -> Iterator[runtimepy.primitives.field.fields.BitFields]
Add a bit-fields primitive to the protocol.
add_field(self, name: str, kind: Union[type[Union[runtimepy.primitives.int.Int8Primitive, runtimepy.primitives.int.Int16Primitive, runtimepy.primitives.int.Int32Primitive, runtimepy.primitives.int.Int64Primitive, runtimepy.primitives.int.Uint8Primitive, runtimepy.primitives.int.Uint16Primitive, runtimepy.primitives.int.Uint32Primitive, runtimepy.primitives.int.Uint64Primitive, runtimepy.primitives.float.HalfPrimitive, runtimepy.primitives.float.FloatPrimitive, runtimepy.primitives.float.DoublePrimitive, runtimepy.primitives.bool.BooleanPrimitive]], str] = None, enum: Union[str, int] = None, serializable: runtimepy.primitives.serializable.base.Serializable = None, track: bool = True, array_length: int = None) -> int
Add a new field to the protocol.
add_serializable(self, name: str, serializable: runtimepy.primitives.serializable.base.Serializable, array_length: int = None) -> int
Add a serializable instance.
register_name(self, name: str) -> int
Register the field name.
trace_size(self, logger: Union[logging.Logger, logging.LoggerAdapter[Any]]) -> None
Log a size trace.
value(self, name: str, resolve_enum: bool = True) -> Union[int, float, bool, str]
Get the value of a field belonging to the protocol.

Readonly properties defined here:
size
Get this protocol's size in bytes.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
Data
        LoggerType = typing.Union[logging.Logger, logging.LoggerAdapter[typing.Any]]
ProtocolPrimitive = typing.Union[int, float, bool, str]
SerializableMap = dict[str, runtimepy.primitives.serializable.base.Serializable]
T = ~T