Debian Codegraph @

third_party/rust/uniffi_bindgen/src/bindings/python/templates/BytesHelper.py

raw
1 class _UniffiConverterBytes(_UniffiConverterRustBuffer):
2 @staticmethod
3 def read(buf):
4 size = buf.read_i32()
5 if size < 0:
6 raise InternalError("Unexpected negative byte string length")
7 return buf.read(size)
8
9 @staticmethod
10 def check_lower(value):
11 try:
12 memoryview(value)
13 except TypeError:
14 raise TypeError("a bytes-like object is required, not {!r}".format(type(value).__name__))
15
16 @staticmethod
17 def write(value, buf):
18 buf.write_i32(len(value))
19 buf.write(value)