cbor: prepare for publishing as standalone crate

- Add an example of usage
- Add a minimal README, including the example code
- Document public items
- Add more info to Cargo.toml
This commit is contained in:
David Drysdale
2021-06-09 10:12:55 +01:00
committed by kaczmarczyck
parent 7719078d46
commit 3aca5fbc74
7 changed files with 200 additions and 2 deletions

View File

@@ -12,9 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Functionality for serializing CBOR values into bytes.
use super::values::{Constants, Value};
use alloc::vec::Vec;
/// Convert a [`Value`] to serialized CBOR data, consuming it along the way and appending to the provided vector.
/// Returns a `bool` indicating whether conversion succeeded.
pub fn write(value: Value, encoded_cbor: &mut Vec<u8>) -> bool {
let mut writer = Writer::new(encoded_cbor);
writer.encode_cbor(value, Writer::MAX_NESTING_DEPTH)