| # 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.protocolpayloads"] |
| add_ir_path(_ir_path) |
| |
| import fidl_test_protocolpayloads_imported |
| |
| |
| @dataclass |
| class LocalStructPayload: |
| a: int |
| b: int |
| |
| __fidl_kind__ = "struct" |
| __fidl_type__ = "LocalStructPayload" |
| __fidl_raw_type__ = "test.protocolpayloads/LocalStructPayload" |
| |
| # 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.protocolpayloads", |
| "test.protocolpayloads/LocalStructPayload", |
| ) |
| |
| # 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( |
| **{ |
| "a": None, # type: ignore[arg-type,unused-ignore] |
| "b": None, # type: ignore[arg-type,unused-ignore] |
| } |
| ) |
| |
| |
| @dataclass |
| class MainProtocolOnAnonRequest: |
| a: int |
| b: int |
| |
| __fidl_kind__ = "struct" |
| __fidl_type__ = "MainProtocolOnAnonRequest" |
| __fidl_raw_type__ = "test.protocolpayloads/MainProtocolOnAnonRequest" |
| |
| # 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.protocolpayloads", |
| "test.protocolpayloads/MainProtocolOnAnonRequest", |
| ) |
| |
| # 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( |
| **{ |
| "a": None, # type: ignore[arg-type,unused-ignore] |
| "b": None, # type: ignore[arg-type,unused-ignore] |
| } |
| ) |
| |
| |
| @dataclass |
| class MainProtocolOneWayAnonRequest: |
| a: int |
| b: int |
| |
| __fidl_kind__ = "struct" |
| __fidl_type__ = "MainProtocolOneWayAnonRequest" |
| __fidl_raw_type__ = "test.protocolpayloads/MainProtocolOneWayAnonRequest" |
| |
| # 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.protocolpayloads", |
| "test.protocolpayloads/MainProtocolOneWayAnonRequest", |
| ) |
| |
| # 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( |
| **{ |
| "a": None, # type: ignore[arg-type,unused-ignore] |
| "b": None, # type: ignore[arg-type,unused-ignore] |
| } |
| ) |
| |
| |
| @dataclass |
| class MainProtocolTwoWayAnonRequest: |
| a: int |
| b: int |
| |
| __fidl_kind__ = "struct" |
| __fidl_type__ = "MainProtocolTwoWayAnonRequest" |
| __fidl_raw_type__ = "test.protocolpayloads/MainProtocolTwoWayAnonRequest" |
| |
| # 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.protocolpayloads", |
| "test.protocolpayloads/MainProtocolTwoWayAnonRequest", |
| ) |
| |
| # 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( |
| **{ |
| "a": None, # type: ignore[arg-type,unused-ignore] |
| "b": None, # type: ignore[arg-type,unused-ignore] |
| } |
| ) |
| |
| |
| @dataclass |
| class MainProtocolTwoWayAnonResponse: |
| a: int |
| b: int |
| |
| __fidl_kind__ = "struct" |
| __fidl_type__ = "MainProtocolTwoWayAnonResponse" |
| __fidl_raw_type__ = "test.protocolpayloads/MainProtocolTwoWayAnonResponse" |
| |
| # 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.protocolpayloads", |
| "test.protocolpayloads/MainProtocolTwoWayAnonResponse", |
| ) |
| |
| # 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( |
| **{ |
| "a": None, # type: ignore[arg-type,unused-ignore] |
| "b": None, # type: ignore[arg-type,unused-ignore] |
| } |
| ) |
| |
| |
| @dataclass |
| class MainProtocolTwoWayAnonWithErrorRequest: |
| a: int |
| b: int |
| |
| __fidl_kind__ = "struct" |
| __fidl_type__ = "MainProtocolTwoWayAnonWithErrorRequest" |
| __fidl_raw_type__ = ( |
| "test.protocolpayloads/MainProtocolTwoWayAnonWithErrorRequest" |
| ) |
| |
| # 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.protocolpayloads", |
| "test.protocolpayloads/MainProtocolTwoWayAnonWithErrorRequest", |
| ) |
| |
| # 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( |
| **{ |
| "a": None, # type: ignore[arg-type,unused-ignore] |
| "b": None, # type: ignore[arg-type,unused-ignore] |
| } |
| ) |
| |
| |
| @dataclass |
| class MainProtocolTwoWayAnonWithErrorResponse: |
| a: int |
| b: int |
| |
| __fidl_kind__ = "struct" |
| __fidl_type__ = "MainProtocolTwoWayAnonWithErrorResponse" |
| __fidl_raw_type__ = ( |
| "test.protocolpayloads/MainProtocol_TwoWayAnonWithError_Response" |
| ) |
| |
| # 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.protocolpayloads", |
| "test.protocolpayloads/MainProtocol_TwoWayAnonWithError_Response", |
| ) |
| |
| # 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( |
| **{ |
| "a": None, # type: ignore[arg-type,unused-ignore] |
| "b": None, # type: ignore[arg-type,unused-ignore] |
| } |
| ) |
| |
| |
| class MainProtocolTwoWayAnonWithErrorResult: |
| _response: typing.Optional[MainProtocolTwoWayAnonWithErrorResponse] |
| _err: typing.Optional[int] |
| |
| __fidl_kind__ = "union" |
| __fidl_type__ = "MainProtocolTwoWayAnonWithErrorResult" |
| __fidl_raw_type__ = ( |
| "test.protocolpayloads/MainProtocol_TwoWayAnonWithError_Result" |
| ) |
| _is_result = True |
| |
| def __eq__(self, other: object) -> bool: |
| if not isinstance(other, type(self)): |
| return False |
| if self.response != other.response: |
| return False |
| if self.err != other.err: |
| return False |
| return True |
| |
| def __repr__(self) -> str: |
| """Returns the union repr in the format <'foo.bar.baz/FooUnion' object({value})> |
| |
| If {value} is not set, will write None.""" |
| variant = "" |
| if self.response: |
| variant = f"response={self.response!r}" |
| if self.err: |
| variant = f"err={self.err!r}" |
| return f"<'{self.__fidl_type__}' object({variant})>" |
| |
| def __init__( |
| self, |
| response: typing.Optional[ |
| MainProtocolTwoWayAnonWithErrorResponse |
| ] = None, |
| err: typing.Optional[int] = None, |
| _empty: typing.Optional[tuple[()]] = None, |
| ): |
| object.__init__(self) |
| if _empty is not None: |
| return |
| |
| number_of_variants = 0 |
| variants = [] |
| |
| if response is not None: |
| self._response = response |
| variants.append("response") |
| number_of_variants += 1 |
| if err is not None: |
| self._err = err |
| variants.append("err") |
| number_of_variants += 1 |
| if number_of_variants > 1: |
| raise TypeError( |
| f"Exactly one variant must be specified for {self.__fidl_raw_type__}: {variants}" |
| ) |
| |
| @property |
| def response(self) -> MainProtocolTwoWayAnonWithErrorResponse | None: |
| return getattr(self, "_response", None) |
| |
| @property |
| def err(self) -> int | None: |
| return getattr(self, "_err", None) |
| |
| # 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.protocolpayloads", |
| "test.protocolpayloads/MainProtocol_TwoWayAnonWithError_Result", |
| ) |
| |
| def unwrap(self) -> MainProtocolTwoWayAnonWithErrorResponse: |
| """Returns the response if result does not contain an error. Otherwise, raises an exception.""" |
| try: |
| if ( |
| hasattr(self, "_framework_err") |
| and self._framework_err is not None |
| ): |
| raise AssertionError( |
| f"{self.__fidl_raw_type__} framework error {self._framework_err}" |
| ) |
| except AttributeError: |
| pass |
| try: |
| if hasattr(self, "_err") and self._err is not None: |
| raise AssertionError( |
| f"{self.__fidl_raw_type__} error {self._err}" |
| ) |
| except AttributeError: |
| pass |
| |
| assert ( |
| self._response is not None |
| ), f"Failed to unwrap {self.__fidl_raw_type__}. Result does not contain an error or response." |
| return self._response |
| |
| @classmethod |
| def make_default(cls) -> typing.Self: |
| return cls(_empty=()) |
| |
| |
| class MainProtocolTwoWayImportWithErrorResult: |
| _response: typing.Optional[ |
| fidl_test_protocolpayloads_imported.ImportStructPayload |
| ] |
| _err: typing.Optional[int] |
| |
| __fidl_kind__ = "union" |
| __fidl_type__ = "MainProtocolTwoWayImportWithErrorResult" |
| __fidl_raw_type__ = ( |
| "test.protocolpayloads/MainProtocol_TwoWayImportWithError_Result" |
| ) |
| _is_result = True |
| |
| def __eq__(self, other: object) -> bool: |
| if not isinstance(other, type(self)): |
| return False |
| if self.response != other.response: |
| return False |
| if self.err != other.err: |
| return False |
| return True |
| |
| def __repr__(self) -> str: |
| """Returns the union repr in the format <'foo.bar.baz/FooUnion' object({value})> |
| |
| If {value} is not set, will write None.""" |
| variant = "" |
| if self.response: |
| variant = f"response={self.response!r}" |
| if self.err: |
| variant = f"err={self.err!r}" |
| return f"<'{self.__fidl_type__}' object({variant})>" |
| |
| def __init__( |
| self, |
| response: typing.Optional[ |
| fidl_test_protocolpayloads_imported.ImportStructPayload |
| ] = None, |
| err: typing.Optional[int] = None, |
| _empty: typing.Optional[tuple[()]] = None, |
| ): |
| object.__init__(self) |
| if _empty is not None: |
| return |
| |
| number_of_variants = 0 |
| variants = [] |
| |
| if response is not None: |
| self._response = response |
| variants.append("response") |
| number_of_variants += 1 |
| if err is not None: |
| self._err = err |
| variants.append("err") |
| number_of_variants += 1 |
| if number_of_variants > 1: |
| raise TypeError( |
| f"Exactly one variant must be specified for {self.__fidl_raw_type__}: {variants}" |
| ) |
| |
| @property |
| def response( |
| self, |
| ) -> fidl_test_protocolpayloads_imported.ImportStructPayload | None: |
| return getattr(self, "_response", None) |
| |
| @property |
| def err(self) -> int | None: |
| return getattr(self, "_err", None) |
| |
| # 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.protocolpayloads", |
| "test.protocolpayloads/MainProtocol_TwoWayImportWithError_Result", |
| ) |
| |
| def unwrap(self) -> fidl_test_protocolpayloads_imported.ImportStructPayload: |
| """Returns the response if result does not contain an error. Otherwise, raises an exception.""" |
| try: |
| if ( |
| hasattr(self, "_framework_err") |
| and self._framework_err is not None |
| ): |
| raise AssertionError( |
| f"{self.__fidl_raw_type__} framework error {self._framework_err}" |
| ) |
| except AttributeError: |
| pass |
| try: |
| if hasattr(self, "_err") and self._err is not None: |
| raise AssertionError( |
| f"{self.__fidl_raw_type__} error {self._err}" |
| ) |
| except AttributeError: |
| pass |
| |
| assert ( |
| self._response is not None |
| ), f"Failed to unwrap {self.__fidl_raw_type__}. Result does not contain an error or response." |
| return self._response |
| |
| @classmethod |
| def make_default(cls) -> typing.Self: |
| return cls(_empty=()) |
| |
| |
| class MainProtocolTwoWayLocalWithErrorResult: |
| _response: typing.Optional[LocalStructPayload] |
| _err: typing.Optional[int] |
| |
| __fidl_kind__ = "union" |
| __fidl_type__ = "MainProtocolTwoWayLocalWithErrorResult" |
| __fidl_raw_type__ = ( |
| "test.protocolpayloads/MainProtocol_TwoWayLocalWithError_Result" |
| ) |
| _is_result = True |
| |
| def __eq__(self, other: object) -> bool: |
| if not isinstance(other, type(self)): |
| return False |
| if self.response != other.response: |
| return False |
| if self.err != other.err: |
| return False |
| return True |
| |
| def __repr__(self) -> str: |
| """Returns the union repr in the format <'foo.bar.baz/FooUnion' object({value})> |
| |
| If {value} is not set, will write None.""" |
| variant = "" |
| if self.response: |
| variant = f"response={self.response!r}" |
| if self.err: |
| variant = f"err={self.err!r}" |
| return f"<'{self.__fidl_type__}' object({variant})>" |
| |
| def __init__( |
| self, |
| response: typing.Optional[LocalStructPayload] = None, |
| err: typing.Optional[int] = None, |
| _empty: typing.Optional[tuple[()]] = None, |
| ): |
| object.__init__(self) |
| if _empty is not None: |
| return |
| |
| number_of_variants = 0 |
| variants = [] |
| |
| if response is not None: |
| self._response = response |
| variants.append("response") |
| number_of_variants += 1 |
| if err is not None: |
| self._err = err |
| variants.append("err") |
| number_of_variants += 1 |
| if number_of_variants > 1: |
| raise TypeError( |
| f"Exactly one variant must be specified for {self.__fidl_raw_type__}: {variants}" |
| ) |
| |
| @property |
| def response(self) -> LocalStructPayload | None: |
| return getattr(self, "_response", None) |
| |
| @property |
| def err(self) -> int | None: |
| return getattr(self, "_err", None) |
| |
| # 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.protocolpayloads", |
| "test.protocolpayloads/MainProtocol_TwoWayLocalWithError_Result", |
| ) |
| |
| def unwrap(self) -> LocalStructPayload: |
| """Returns the response if result does not contain an error. Otherwise, raises an exception.""" |
| try: |
| if ( |
| hasattr(self, "_framework_err") |
| and self._framework_err is not None |
| ): |
| raise AssertionError( |
| f"{self.__fidl_raw_type__} framework error {self._framework_err}" |
| ) |
| except AttributeError: |
| pass |
| try: |
| if hasattr(self, "_err") and self._err is not None: |
| raise AssertionError( |
| f"{self.__fidl_raw_type__} error {self._err}" |
| ) |
| except AttributeError: |
| pass |
| |
| assert ( |
| self._response is not None |
| ), f"Failed to unwrap {self.__fidl_raw_type__}. Result does not contain an error or response." |
| return self._response |
| |
| @classmethod |
| def make_default(cls) -> typing.Self: |
| return cls(_empty=()) |
| |
| |
| from fidl._client import EventHandlerBase, FidlClient |
| from fidl._server import ServerBase |
| from fidl._fidl_common import ( |
| DomainError, |
| FrameworkError, |
| MethodInfo, |
| FidlProtocolMarker, |
| normalize_identifier, |
| ) |
| |
| from abc import abstractmethod, ABC |
| |
| |
| class MainProtocolServer(ServerBase, ABC): |
| __fidl_kind__ = "server" |
| library = "test.protocolpayloads" |
| method_map: typing.Dict[int, MethodInfo] = { |
| 2602591870026304272: MethodInfo( |
| name="one_way_composed", |
| request_ident="test.protocolpayloads.imported/ImportStructPayload", |
| requires_response=False, |
| empty_response=False, |
| has_result=False, |
| response_identifier="", |
| ), |
| 2542459230546612144: MethodInfo( |
| name="two_way_composed", |
| request_ident="test.protocolpayloads.imported/ImportStructPayload", |
| requires_response=True, |
| empty_response=False, |
| has_result=False, |
| response_identifier="test.protocolpayloads.imported/ImportStructPayload", |
| ), |
| 7681984876526769495: MethodInfo( |
| name="two_way_composed_with_error", |
| request_ident="test.protocolpayloads.imported/ImportStructPayload", |
| requires_response=True, |
| empty_response=False, |
| has_result=True, |
| response_identifier="test.protocolpayloads.imported/ComposedProtocol_TwoWayComposedWithError_Result", |
| ), |
| 7755175439334311701: MethodInfo( |
| name="one_way_local", |
| request_ident="test.protocolpayloads/LocalStructPayload", |
| requires_response=False, |
| empty_response=False, |
| has_result=False, |
| response_identifier="", |
| ), |
| 8374292137648566031: MethodInfo( |
| name="two_way_local", |
| request_ident="test.protocolpayloads/LocalStructPayload", |
| requires_response=True, |
| empty_response=False, |
| has_result=False, |
| response_identifier="test.protocolpayloads/LocalStructPayload", |
| ), |
| 2898559119954589948: MethodInfo( |
| name="two_way_local_with_error", |
| request_ident="test.protocolpayloads/LocalStructPayload", |
| requires_response=True, |
| empty_response=False, |
| has_result=True, |
| response_identifier="test.protocolpayloads/MainProtocol_TwoWayLocalWithError_Result", |
| ), |
| 3344777159365288972: MethodInfo( |
| name="one_way_import", |
| request_ident="test.protocolpayloads.imported/ImportStructPayload", |
| requires_response=False, |
| empty_response=False, |
| has_result=False, |
| response_identifier="", |
| ), |
| 2374708679656510579: MethodInfo( |
| name="two_way_import", |
| request_ident="test.protocolpayloads.imported/ImportStructPayload", |
| requires_response=True, |
| empty_response=False, |
| has_result=False, |
| response_identifier="test.protocolpayloads.imported/ImportStructPayload", |
| ), |
| 4286143084949642173: MethodInfo( |
| name="two_way_import_with_error", |
| request_ident="test.protocolpayloads.imported/ImportStructPayload", |
| requires_response=True, |
| empty_response=False, |
| has_result=True, |
| response_identifier="test.protocolpayloads/MainProtocol_TwoWayImportWithError_Result", |
| ), |
| 811587311021806764: MethodInfo( |
| name="one_way_anon", |
| request_ident="test.protocolpayloads/MainProtocolOneWayAnonRequest", |
| requires_response=False, |
| empty_response=False, |
| has_result=False, |
| response_identifier="", |
| ), |
| 629880979996923737: MethodInfo( |
| name="two_way_anon", |
| request_ident="test.protocolpayloads/MainProtocolTwoWayAnonRequest", |
| requires_response=True, |
| empty_response=False, |
| has_result=False, |
| response_identifier="test.protocolpayloads/MainProtocolTwoWayAnonResponse", |
| ), |
| 6368863385719175734: MethodInfo( |
| name="two_way_anon_with_error", |
| request_ident="test.protocolpayloads/MainProtocolTwoWayAnonWithErrorRequest", |
| requires_response=True, |
| empty_response=False, |
| has_result=True, |
| response_identifier="test.protocolpayloads/MainProtocol_TwoWayAnonWithError_Result", |
| ), |
| } |
| |
| @staticmethod |
| def construct_response_object( |
| response_ident: str, response_obj: typing.Any |
| ) -> typing.Any: |
| import fidl._construct |
| |
| return fidl._construct.construct_response_object( |
| response_ident, response_obj |
| ) |
| |
| OneWayComposedResponse: typing.TypeAlias = None |
| |
| @abstractmethod |
| def one_way_composed( |
| self, |
| request: fidl_test_protocolpayloads_imported.ImportStructPayload, |
| ) -> ( |
| typing.Coroutine[typing.Any, typing.Any, OneWayComposedResponse] |
| | OneWayComposedResponse |
| ): |
| ... |
| |
| TwoWayComposedResponse: typing.TypeAlias = ( |
| fidl_test_protocolpayloads_imported.ImportStructPayload |
| ) |
| |
| @abstractmethod |
| def two_way_composed( |
| self, |
| request: fidl_test_protocolpayloads_imported.ImportStructPayload, |
| ) -> ( |
| typing.Coroutine[typing.Any, typing.Any, TwoWayComposedResponse] |
| | TwoWayComposedResponse |
| ): |
| ... |
| |
| TwoWayComposedWithErrorResponse: typing.TypeAlias = typing.Union[ |
| DomainError, |
| fidl_test_protocolpayloads_imported.ImportStructPayload, |
| ] |
| |
| @abstractmethod |
| def two_way_composed_with_error( |
| self, |
| request: fidl_test_protocolpayloads_imported.ImportStructPayload, |
| ) -> ( |
| typing.Coroutine[ |
| typing.Any, typing.Any, TwoWayComposedWithErrorResponse |
| ] |
| | TwoWayComposedWithErrorResponse |
| ): |
| ... |
| |
| def on_composed( |
| self, |
| *, |
| a: int, |
| ) -> None: |
| msg = fidl_test_protocolpayloads_imported.ImportStructPayload( |
| a, |
| ) |
| self._send_event(1872339328378152762, "test.protocolpayloads", msg) |
| |
| OneWayLocalResponse: typing.TypeAlias = None |
| |
| @abstractmethod |
| def one_way_local( |
| self, |
| request: LocalStructPayload, |
| ) -> ( |
| typing.Coroutine[typing.Any, typing.Any, OneWayLocalResponse] |
| | OneWayLocalResponse |
| ): |
| ... |
| |
| TwoWayLocalResponse: typing.TypeAlias = LocalStructPayload |
| |
| @abstractmethod |
| def two_way_local( |
| self, |
| request: LocalStructPayload, |
| ) -> ( |
| typing.Coroutine[typing.Any, typing.Any, TwoWayLocalResponse] |
| | TwoWayLocalResponse |
| ): |
| ... |
| |
| TwoWayLocalWithErrorResponse: typing.TypeAlias = typing.Union[ |
| DomainError, |
| LocalStructPayload, |
| ] |
| |
| @abstractmethod |
| def two_way_local_with_error( |
| self, |
| request: LocalStructPayload, |
| ) -> ( |
| typing.Coroutine[typing.Any, typing.Any, TwoWayLocalWithErrorResponse] |
| | TwoWayLocalWithErrorResponse |
| ): |
| ... |
| |
| def on_local( |
| self, |
| *, |
| a: int, |
| b: int, |
| ) -> None: |
| msg = LocalStructPayload( |
| a, |
| b, |
| ) |
| self._send_event(5135782819583756313, "test.protocolpayloads", msg) |
| |
| OneWayImportResponse: typing.TypeAlias = None |
| |
| @abstractmethod |
| def one_way_import( |
| self, |
| request: fidl_test_protocolpayloads_imported.ImportStructPayload, |
| ) -> ( |
| typing.Coroutine[typing.Any, typing.Any, OneWayImportResponse] |
| | OneWayImportResponse |
| ): |
| ... |
| |
| TwoWayImportResponse: typing.TypeAlias = ( |
| fidl_test_protocolpayloads_imported.ImportStructPayload |
| ) |
| |
| @abstractmethod |
| def two_way_import( |
| self, |
| request: fidl_test_protocolpayloads_imported.ImportStructPayload, |
| ) -> ( |
| typing.Coroutine[typing.Any, typing.Any, TwoWayImportResponse] |
| | TwoWayImportResponse |
| ): |
| ... |
| |
| TwoWayImportWithErrorResponse: typing.TypeAlias = typing.Union[ |
| DomainError, |
| fidl_test_protocolpayloads_imported.ImportStructPayload, |
| ] |
| |
| @abstractmethod |
| def two_way_import_with_error( |
| self, |
| request: fidl_test_protocolpayloads_imported.ImportStructPayload, |
| ) -> ( |
| typing.Coroutine[typing.Any, typing.Any, TwoWayImportWithErrorResponse] |
| | TwoWayImportWithErrorResponse |
| ): |
| ... |
| |
| def on_import( |
| self, |
| *, |
| a: int, |
| ) -> None: |
| msg = fidl_test_protocolpayloads_imported.ImportStructPayload( |
| a, |
| ) |
| self._send_event(1996489653379631369, "test.protocolpayloads", msg) |
| |
| OneWayAnonResponse: typing.TypeAlias = None |
| |
| @abstractmethod |
| def one_way_anon( |
| self, |
| request: MainProtocolOneWayAnonRequest, |
| ) -> ( |
| typing.Coroutine[typing.Any, typing.Any, OneWayAnonResponse] |
| | OneWayAnonResponse |
| ): |
| ... |
| |
| TwoWayAnonResponse: typing.TypeAlias = MainProtocolTwoWayAnonResponse |
| |
| @abstractmethod |
| def two_way_anon( |
| self, |
| request: MainProtocolTwoWayAnonRequest, |
| ) -> ( |
| typing.Coroutine[typing.Any, typing.Any, TwoWayAnonResponse] |
| | TwoWayAnonResponse |
| ): |
| ... |
| |
| TwoWayAnonWithErrorResponse: typing.TypeAlias = typing.Union[ |
| DomainError, |
| MainProtocolTwoWayAnonWithErrorResponse, |
| ] |
| |
| @abstractmethod |
| def two_way_anon_with_error( |
| self, |
| request: MainProtocolTwoWayAnonWithErrorRequest, |
| ) -> ( |
| typing.Coroutine[typing.Any, typing.Any, TwoWayAnonWithErrorResponse] |
| | TwoWayAnonWithErrorResponse |
| ): |
| ... |
| |
| def on_anon( |
| self, |
| *, |
| a: int, |
| b: int, |
| ) -> None: |
| msg = MainProtocolOnAnonRequest( |
| a, |
| b, |
| ) |
| self._send_event(4815229650203439104, "test.protocolpayloads", msg) |
| |
| |
| class MainProtocolClient(FidlClient): |
| __fidl_kind__ = "client" |
| library = "test.protocolpayloads" |
| |
| @staticmethod |
| def construct_response_object( |
| response_ident: str, response_obj: typing.Any |
| ) -> typing.Any: |
| import fidl._construct |
| |
| return fidl._construct.construct_response_object( |
| response_ident, response_obj |
| ) |
| |
| def one_way_composed( |
| self, |
| *, |
| a: int, |
| ) -> None: |
| msg = fidl_test_protocolpayloads_imported.ImportStructPayload( |
| a, |
| ) |
| |
| self._send_one_way_fidl_request( |
| 0, |
| 2602591870026304272, |
| "test.protocolpayloads", |
| msg, |
| ) |
| |
| def two_way_composed( |
| self, |
| *, |
| a: int, |
| ) -> typing.Coroutine[ |
| typing.Any, |
| typing.Any, |
| fidl_test_protocolpayloads_imported.ImportStructPayload, |
| ]: |
| msg = fidl_test_protocolpayloads_imported.ImportStructPayload( |
| a, |
| ) |
| return self._send_two_way_fidl_request( |
| 2542459230546612144, |
| "test.protocolpayloads", |
| msg, |
| normalize_identifier( |
| "test.protocolpayloads.imported/ImportStructPayload" |
| ), |
| ) |
| |
| def two_way_composed_with_error( |
| self, |
| *, |
| a: int, |
| ) -> typing.Coroutine[ |
| typing.Any, |
| typing.Any, |
| fidl_test_protocolpayloads_imported.ComposedProtocolTwoWayComposedWithErrorResult, |
| ]: |
| msg = fidl_test_protocolpayloads_imported.ImportStructPayload( |
| a, |
| ) |
| return self._send_two_way_fidl_request( |
| 7681984876526769495, |
| "test.protocolpayloads", |
| msg, |
| normalize_identifier( |
| "test.protocolpayloads.imported/ComposedProtocol_TwoWayComposedWithError_Result" |
| ), |
| ) |
| |
| def one_way_local( |
| self, |
| *, |
| a: int, |
| b: int, |
| ) -> None: |
| msg = LocalStructPayload( |
| a, |
| b, |
| ) |
| |
| self._send_one_way_fidl_request( |
| 0, |
| 7755175439334311701, |
| "test.protocolpayloads", |
| msg, |
| ) |
| |
| def two_way_local( |
| self, |
| *, |
| a: int, |
| b: int, |
| ) -> typing.Coroutine[typing.Any, typing.Any, LocalStructPayload]: |
| msg = LocalStructPayload( |
| a, |
| b, |
| ) |
| return self._send_two_way_fidl_request( |
| 8374292137648566031, |
| "test.protocolpayloads", |
| msg, |
| normalize_identifier("test.protocolpayloads/LocalStructPayload"), |
| ) |
| |
| def two_way_local_with_error( |
| self, |
| *, |
| a: int, |
| b: int, |
| ) -> typing.Coroutine[ |
| typing.Any, typing.Any, MainProtocolTwoWayLocalWithErrorResult |
| ]: |
| msg = LocalStructPayload( |
| a, |
| b, |
| ) |
| return self._send_two_way_fidl_request( |
| 2898559119954589948, |
| "test.protocolpayloads", |
| msg, |
| normalize_identifier( |
| "test.protocolpayloads/MainProtocol_TwoWayLocalWithError_Result" |
| ), |
| ) |
| |
| def one_way_import( |
| self, |
| *, |
| a: int, |
| ) -> None: |
| msg = fidl_test_protocolpayloads_imported.ImportStructPayload( |
| a, |
| ) |
| |
| self._send_one_way_fidl_request( |
| 0, |
| 3344777159365288972, |
| "test.protocolpayloads", |
| msg, |
| ) |
| |
| def two_way_import( |
| self, |
| *, |
| a: int, |
| ) -> typing.Coroutine[ |
| typing.Any, |
| typing.Any, |
| fidl_test_protocolpayloads_imported.ImportStructPayload, |
| ]: |
| msg = fidl_test_protocolpayloads_imported.ImportStructPayload( |
| a, |
| ) |
| return self._send_two_way_fidl_request( |
| 2374708679656510579, |
| "test.protocolpayloads", |
| msg, |
| normalize_identifier( |
| "test.protocolpayloads.imported/ImportStructPayload" |
| ), |
| ) |
| |
| def two_way_import_with_error( |
| self, |
| *, |
| a: int, |
| ) -> typing.Coroutine[ |
| typing.Any, typing.Any, MainProtocolTwoWayImportWithErrorResult |
| ]: |
| msg = fidl_test_protocolpayloads_imported.ImportStructPayload( |
| a, |
| ) |
| return self._send_two_way_fidl_request( |
| 4286143084949642173, |
| "test.protocolpayloads", |
| msg, |
| normalize_identifier( |
| "test.protocolpayloads/MainProtocol_TwoWayImportWithError_Result" |
| ), |
| ) |
| |
| def one_way_anon( |
| self, |
| *, |
| a: int, |
| b: int, |
| ) -> None: |
| msg = MainProtocolOneWayAnonRequest( |
| a, |
| b, |
| ) |
| |
| self._send_one_way_fidl_request( |
| 0, |
| 811587311021806764, |
| "test.protocolpayloads", |
| msg, |
| ) |
| |
| def two_way_anon( |
| self, |
| *, |
| a: int, |
| b: int, |
| ) -> typing.Coroutine[ |
| typing.Any, typing.Any, MainProtocolTwoWayAnonResponse |
| ]: |
| msg = MainProtocolTwoWayAnonRequest( |
| a, |
| b, |
| ) |
| return self._send_two_way_fidl_request( |
| 629880979996923737, |
| "test.protocolpayloads", |
| msg, |
| normalize_identifier( |
| "test.protocolpayloads/MainProtocolTwoWayAnonResponse" |
| ), |
| ) |
| |
| def two_way_anon_with_error( |
| self, |
| *, |
| a: int, |
| b: int, |
| ) -> typing.Coroutine[ |
| typing.Any, typing.Any, MainProtocolTwoWayAnonWithErrorResult |
| ]: |
| msg = MainProtocolTwoWayAnonWithErrorRequest( |
| a, |
| b, |
| ) |
| return self._send_two_way_fidl_request( |
| 6368863385719175734, |
| "test.protocolpayloads", |
| msg, |
| normalize_identifier( |
| "test.protocolpayloads/MainProtocol_TwoWayAnonWithError_Result" |
| ), |
| ) |
| |
| |
| class MainProtocolEventHandler(EventHandlerBase, ABC): |
| __fidl_kind__ = "event_handler" |
| library = "test.protocolpayloads" |
| method_map: typing.Dict[int, MethodInfo] = { |
| 1872339328378152762: MethodInfo( |
| name="on_composed", |
| request_ident="test.protocolpayloads.imported/ImportStructPayload", |
| requires_response=False, |
| empty_response=False, |
| has_result=False, |
| response_identifier=None, |
| ), |
| 5135782819583756313: MethodInfo( |
| name="on_local", |
| request_ident="test.protocolpayloads/LocalStructPayload", |
| requires_response=False, |
| empty_response=False, |
| has_result=False, |
| response_identifier=None, |
| ), |
| 1996489653379631369: MethodInfo( |
| name="on_import", |
| request_ident="test.protocolpayloads.imported/ImportStructPayload", |
| requires_response=False, |
| empty_response=False, |
| has_result=False, |
| response_identifier=None, |
| ), |
| 4815229650203439104: MethodInfo( |
| name="on_anon", |
| request_ident="test.protocolpayloads/MainProtocolOnAnonRequest", |
| requires_response=False, |
| empty_response=False, |
| has_result=False, |
| response_identifier=None, |
| ), |
| } |
| |
| @staticmethod |
| def construct_response_object( |
| response_ident: str, response_obj: typing.Any |
| ) -> typing.Any: |
| import fidl._construct |
| |
| return fidl._construct.construct_response_object( |
| response_ident, response_obj |
| ) |
| |
| @abstractmethod |
| def on_composed( |
| self, |
| request: fidl_test_protocolpayloads_imported.ImportStructPayload, |
| ) -> typing.Coroutine[typing.Any, typing.Any, None] | None: |
| ... |
| |
| @abstractmethod |
| def on_local( |
| self, |
| request: LocalStructPayload, |
| ) -> typing.Coroutine[typing.Any, typing.Any, None] | None: |
| ... |
| |
| @abstractmethod |
| def on_import( |
| self, |
| request: fidl_test_protocolpayloads_imported.ImportStructPayload, |
| ) -> typing.Coroutine[typing.Any, typing.Any, None] | None: |
| ... |
| |
| @abstractmethod |
| def on_anon( |
| self, |
| request: MainProtocolOnAnonRequest, |
| ) -> typing.Coroutine[typing.Any, typing.Any, None] | None: |
| ... |
| |
| |
| MainProtocolMarker = FidlProtocolMarker( |
| "(nondiscoverable) test.protocolpayloads/MainProtocol" |
| ) |