MCPcopy
hub / github.com/pika/pika / decode_short_string

Function decode_short_string

pika/data.py:44–56  ·  view source on GitHub ↗

Decode a short string value from ``encoded`` data at ``offset``.

(encoded: bytes,
                        offset: int)

Source from the content-addressed store, hash-verified

42
43
44def decode_short_string(encoded: bytes,
45 offset: int) -> Tuple[Union[str, bytes], int]:
46 """Decode a short string value from ``encoded`` data at ``offset``.
47 """
48 length = struct.unpack_from('B', encoded, offset)[0]
49 offset += 1
50 value = encoded[offset:offset + length]
51 try:
52 value = value.decode('utf8') # type: ignore[assignment]
53 except UnicodeDecodeError:
54 pass
55 offset += length
56 return value, offset
57
58
59def encode_table(pieces: List[bytes], table: Optional[Dict[str, Any]]) -> int:

Callers 1

decode_tableFunction · 0.85

Calls 1

decodeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…