跳转到正文

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 = 1024

MAX_VALUE_DEPTH ​

python
MAX_VALUE_DEPTH = 128

MAX_VALUE_NODES ​

python
MAX_VALUE_NODES = 1000000

MAX_VALUE_BYTES ​

python
MAX_VALUE_BYTES = 16 * 1024 * 1024

schema_digest ​

python
def schema_digest(schema: dict) -> str

SDK 说明:

text
Validate a canonical schema and compute its portable structural digest.

Binding ​

python
class Binding

SDK 说明:

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) -> Binding

compile_signature ​

python
def compile_signature(request, response) -> Signature

binding_from_schema ​

python
def binding_from_schema(schema: dict, root: int | None=None) -> Binding

SDK 说明:

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 Value

SDK 说明:

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) -> bytes

decode_bytes ​

python
def decode_bytes(binding: Binding, data)

Neomega · 使用、开发与参考文档