| # WARNING: This file is machine generated by fidlgen. |
| |
| from __future__ import annotations |
| |
| from dataclasses import dataclass |
| from fidl_codec import add_ir_path, encode_fidl_object |
| import sys |
| import typing |
| import enum |
| |
| import fidl |
| from fidl._ir import get_fidl_ir_map |
| |
| _ir_path = get_fidl_ir_map()["test.vectors"] |
| add_ir_path(_ir_path) |
| |
| |
| @dataclass |
| class ExampleUseOfVectors: |
| vector_of_uint8: typing.Sequence[int] |
| vector_of_vector_of_bool: typing.Sequence[typing.Sequence[bool]] |
| |
| __fidl_kind__ = "struct" |
| __fidl_type__ = "ExampleUseOfVectors" |
| __fidl_raw_type__ = "test.vectors/ExampleUseOfVectors" |
| |
| # TODO(https://fxbug.dev/394421154): We should probably remove this method when we |
| # start making breaking changes. |
| def __getitem__(self, item: str): # type: ignore |
| if not isinstance(item, str): |
| raise TypeError("Subscripted item must be a string") |
| return getattr(self, item) |
| |
| # TODO(https://fxbug.dev/394421154): We should probably return a more readable type. |
| def encode(self) -> tuple[bytes, list[tuple[int, int, int, int, int]]]: |
| return encode_fidl_object( |
| self, "test.vectors", "test.vectors/ExampleUseOfVectors" |
| ) |
| |
| # TODO(https://fxbug.dev/394421154): Assigning None (incorrectly) to each type is a consequence |
| # of needing to support creation of a "default object" before decoding. |
| @classmethod |
| def make_default(cls) -> typing.Self: |
| return cls( |
| **{ |
| "vector_of_uint8": None, # type: ignore[arg-type,unused-ignore] |
| "vector_of_vector_of_bool": None, # type: ignore[arg-type,unused-ignore] |
| } |
| ) |