Structured RPC response with internal request ID correlation. The request ID is managed internally for correlation and is not exposed in the public API. Users should only interact with success, data, and raw_line.
| 50 | |
| 51 | @dataclass |
| 52 | class RpcResponse: |
| 53 | """Structured RPC response with internal request ID correlation. |
| 54 | |
| 55 | The request ID is managed internally for correlation and is not exposed |
| 56 | in the public API. Users should only interact with success, data, and raw_line. |
| 57 | """ |
| 58 | |
| 59 | success: bool |
| 60 | data: dict[str, Any] |
| 61 | raw_line: str |
| 62 | _id: int = 0 # Internal: Request ID from JSON-RPC 2.0 (always present, hidden from public API) |
| 63 | |
| 64 | def get(self, key: str, default: Any = None) -> Any: |
| 65 | """Get value from response data.""" |
| 66 | return self.data.get(key, default) |
| 67 | |
| 68 | def __getitem__(self, key: str) -> Any: |
| 69 | """Allow dict-like access to response data.""" |
| 70 | return self.data[key] |
| 71 | |
| 72 | def __contains__(self, key: str) -> bool: |
| 73 | """Check if key exists in response data.""" |
| 74 | return key in self.data |
| 75 | |
| 76 | |
| 77 | class RpcTimeoutError(TimeoutError): |
no outgoing calls