pbbson 0.2.2

Utilities for pbjson to BSON conversion
# pbbson-rs

Utilities for [pbjson](https://crates.io/crates/pbjson-types) to [BSON](https://crates.io/crates/bson) conversions.

[![License](http://img.shields.io/badge/Licence-MIT-blue.svg)](LICENSE)
[![Arch](https://img.shields.io/badge/Arch-aarch64%20|%20amd64%20|%20armv7-blue.svg)]()

## Installing

```shell
$ cargo add pbbson
```

## Testing

```shell
$ make check
```

## Using

### Convert a Prost Protobuf message into a BSON Document

```rust
use bson::Document;
use pbbson::Model;

let doc: Document = Model::try_from(&message).unwrap().into();
```

### Convert a BSON Document into a Prost Protobuf message 

```rust
let my_struct: StructType = model.try_into().unwrap();
```

## Status

### Protobuf to BSON

- [x] bool → Bool
- [x] double → Double
- [x] int32 → Int32
- [ ] int64 → Int64
- [x] repeated → List
- [x] string → String
- [x] uint32 → Int64
- [x] uint64 → String
- [ ] [pbjson types](https://github.com/influxdata/pbjson/blob/main/pbjson-types/protos/google/protobuf/types.proto)
  - [ ] Any
  - [ ] Api
  - [ ] Descriptor
  - [x] Duration → String (Go-style duration string with humanized suffixes)
  - [ ] Empty
  - [ ] FieldMask
  - [ ] SourceContext
  - [x] Struct → Document
  - [x] Timestamp → DateTime
  - [ ] Type
  - [ ] Wrappers

### BSON to Protobuf

- [x] Array
- [ ] Binary
  - [ ] Encrypted
  - [ ] Function
  - [ ] Generic
  - [ ] Md5 → bytes
  - [x] Md5 → String
  - [ ] Sensitive
  - [ ] Uuid → bytes
  - [x] Uuid → String
- [x] Boolean
- [x] DateTime → Timestamp
- [ ] Decimal128
- [x] Document → Struct
- [x] Double
- [x] Int32
- [x] Int64
- [ ] JavaScriptCode
- [ ] JavaScriptCodeWithScope
- [x] Null
- [x] ObjectId → String (20-byte base32hex encoded xid)
- [ ] RegularExpression
- [x] String → Duration
- [x] String → String
- [ ] String → Timestamp
- [ ] Timestamp