外观
bus_values API
模块说明
text
Bounded native and dynamic values for the versioned structural Bus format.
Schema identity depends only on structure, including recursive structure, not
Python class names. Dataclass fields may supply ``metadata={'bus': 'wireName'}``.
Bare ``int`` is intentionally unsupported: use an explicit bus_types width.
Dataclasses are data-only: generated initialization, ordinary attribute access,
no InitVar, descriptor fields, custom allocation or post-init hooks. Standard
frozen, slots and keyword-only declarations remain supported.MAX_SCHEMA_NODES
python
MAX_SCHEMA_NODES = 1024MAX_VALUE_DEPTH
python
MAX_VALUE_DEPTH = 128MAX_VALUE_NODES
python
MAX_VALUE_NODES = 1000000MAX_VALUE_BYTES
python
MAX_VALUE_BYTES = 16 * 1024 * 1024schema_digest
python
def schema_digest(schema: dict) -> strSDK 说明:
text
Validate a canonical schema and compute its portable structural digest.Binding
python
class BindingSDK 说明:
text
Compiled native type, or a generated type rooted in a canonical schema.Binding.__init__
python
def __init__(self, schema, root, nodes, specs, mapping, local_root)Binding.schema
python
@property
def schema(self)Binding.native_type
python
@property
def native_type(self)Binding.encode
python
def encode(self, native)Binding.decode
python
def decode(self, wire)Binding.encode_bytes
python
def encode_bytes(self, native)Binding.decode_bytes
python
def decode_bytes(self, data)Binding.digest
python
self.digest公开实例属性,在 __init__ 中设置。
Binding.root
python
self.root公开实例属性,在 __init__ 中设置。
Signature
python
@dataclasses.dataclass(frozen=True)
class Signature字段(包含继承字段):
Signature.schema
python
schema: dict数据类字段;声明于 bus_values.Signature。
Signature.digest
python
digest: str数据类字段;声明于 bus_values.Signature。
Signature.request
python
request: Binding数据类字段;声明于 bus_values.Signature。
Signature.response
python
response: Binding数据类字段;声明于 bus_values.Signature。
compile_type
python
def compile_type(annotation) -> Bindingcompile_signature
python
def compile_signature(request, response) -> Signaturebinding_from_schema
python
def binding_from_schema(schema: dict, root: int | None=None) -> BindingSDK 说明:
text
Generate native dataclasses from a validated canonical remote schema.
Root is a canonical node ID and defaults to the first declared root.
``binding.native_type`` exposes the generated root dataclass when applicable.
Arbitrary wire field names receive safe Python attributes; inspect each
dataclass field's ``metadata['bus']`` for the exact original name.
Live generated classes are reused by complete schema digest and node ID;
returned bindings and their codec state are always independent.Value
python
class ValueSDK 说明:
text
Validated dynamic wire value that uses exactly the native codec contract.Value.__init__
python
def __init__(self, schema: dict, root: int, wire: list)Value.schema
python
@property
def schema(self)Value.wire
python
@property
def wire(self)Value.digest
python
@property
def digest(self)Value.decode
python
def decode(self, binding: Binding | None=None)Value.root
python
self.root公开实例属性,在 __init__ 中设置。
encode_bytes
python
def encode_bytes(binding: Binding, native) -> bytesdecode_bytes
python
def decode_bytes(binding: Binding, data)