MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / _encode_code

Function _encode_code

bson/__init__.py:821–829  ·  view source on GitHub ↗

Encode bson.code.Code.

(name: bytes, value: Code, dummy: Any, opts: CodecOptions[Any])

Source from the content-addressed store, hash-verified

819
820
821def _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
832def _encode_int(name: bytes, value: int, dummy0: Any, dummy1: Any) -> bytes:

Callers

nothing calls this directly

Calls 2

_make_c_stringFunction · 0.85
_dict_to_bsonFunction · 0.85

Tested by

no test coverage detected