Encode bson.code.Code.
(name: bytes, value: Code, dummy: Any, opts: CodecOptions[Any])
| 819 | |
| 820 | |
| 821 | def _encode_code(name: bytes, value: Code, dummy: Any, opts: CodecOptions[Any]) -> bytes: |
| 822 | """Encode bson.code.Code.""" |
| 823 | cstring = _make_c_string(value) |
| 824 | cstrlen = len(cstring) |
| 825 | if value.scope is None: |
| 826 | return b"\x0D" + name + _PACK_INT(cstrlen) + cstring |
| 827 | scope = _dict_to_bson(value.scope, False, opts, False) |
| 828 | full_length = _PACK_INT(8 + cstrlen + len(scope)) |
| 829 | return b"\x0F" + name + full_length + _PACK_INT(cstrlen) + cstring + scope |
| 830 | |
| 831 | |
| 832 | def _encode_int(name: bytes, value: int, dummy0: Any, dummy1: Any) -> bytes: |
nothing calls this directly
no test coverage detected