Decode a BSON document into result.
(
data: Any,
view: Any,
position: int,
obj_end: int,
opts: CodecOptions[Any],
result: Any = None,
raw_array: bool = False,
)
| 596 | |
| 597 | |
| 598 | def _elements_to_dict( |
| 599 | data: Any, |
| 600 | view: Any, |
| 601 | position: int, |
| 602 | obj_end: int, |
| 603 | opts: CodecOptions[Any], |
| 604 | result: Any = None, |
| 605 | raw_array: bool = False, |
| 606 | ) -> Any: |
| 607 | """Decode a BSON document into result.""" |
| 608 | if result is None: |
| 609 | result = opts.document_class() |
| 610 | end = obj_end - 1 |
| 611 | while position < end: |
| 612 | key, value, position = _element_to_dict( |
| 613 | data, view, position, obj_end, opts, raw_array=raw_array |
| 614 | ) |
| 615 | result[key] = value |
| 616 | if position != obj_end: |
| 617 | raise InvalidBSON("bad object or element length") |
| 618 | return result |
| 619 | |
| 620 | |
| 621 | def _bson_to_dict(data: Any, opts: CodecOptions[_DocumentType]) -> _DocumentType: |
no test coverage detected