| 1 |
// Copyright (C) MongoDB, Inc. 2022-present. |
| 2 |
// |
| 3 |
// Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 |
// not use this file except in compliance with the License. You may obtain |
| 5 |
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 |
| 6 |
|
| 7 |
// Package bsoncore is intended for internal use only. It is made available to |
| 8 |
// facilitate use cases that require access to internal MongoDB driver |
| 9 |
// functionality and state. The API of this package is not stable and there is |
| 10 |
// no backward compatibility guarantee. |
| 11 |
// |
| 12 |
// WARNING: THIS PACKAGE IS EXPERIMENTAL AND MAY BE MODIFIED OR REMOVED WITHOUT |
| 13 |
// NOTICE! USE WITH EXTREME CAUTION! |
| 14 |
// |
| 15 |
// Package bsoncore contains functions that can be used to encode and decode |
| 16 |
// BSON elements and values to or from a slice of bytes. These functions are |
| 17 |
// aimed at allowing low level manipulation of BSON and can be used to build a |
| 18 |
// higher level BSON library. |
| 19 |
// |
| 20 |
// The Read* functions within this package return the values of the element and |
| 21 |
// a boolean indicating if the values are valid. A boolean was used instead of |
| 22 |
// an error because any error that would be returned would be the same: not |
| 23 |
// enough bytes. This library attempts to do no validation, it will only return |
| 24 |
// false if there are not enough bytes for an item to be read. For example, the |
| 25 |
// ReadDocument function checks the length, if that length is larger than the |
| 26 |
// number of bytes available, it will return false, if there are enough bytes, |
| 27 |
// it will return those bytes and true. It is the consumers responsibility to |
| 28 |
// validate those bytes. |
| 29 |
// |
| 30 |
// The Append* functions within this package will append the type value to the |
| 31 |
// given dst slice. If the slice has enough capacity, it will not grow the |
| 32 |
// slice. The Append*Element functions within this package operate in the same |
| 33 |
// way, but additionally append the BSON type and the key before the value. |
| 34 |
package bsoncore |