(arg: Optional[Union[str, bytes, FfiByteBuffer]])
| 38 | |
| 39 | |
| 40 | def _decode_bytes(arg: Optional[Union[str, bytes, FfiByteBuffer]]) -> bytes: |
| 41 | if isinstance(arg, FfiByteBuffer): |
| 42 | return string_at(arg.data, arg.length) |
| 43 | if isinstance(arg, memoryview): |
| 44 | return string_at(arg.obj, arg.nbytes) |
| 45 | if isinstance(arg, bytearray): |
| 46 | return arg |
| 47 | if arg is not None: |
| 48 | if isinstance(arg, str): |
| 49 | return arg.encode("utf-8") |
| 50 | return bytearray() |
| 51 | |
| 52 | |
| 53 | def _encode_bytes(arg: Optional[Union[str, bytes, FfiByteBuffer]]) -> FfiByteBuffer: |
no outgoing calls
no test coverage detected