Skip to content

Commit

Permalink
feat: add bson ObjectId impl (#340)
Browse files Browse the repository at this point in the history
Co-authored-by: gustavo-shigueo <[email protected]>
  • Loading branch information
ShaunSHamilton and gustavo-shigueo authored Jul 24, 2024
1 parent 68f2f22 commit e268437
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# master
### Breaking
### Features

- The `bson-uuid-impl` feature now supports `bson::oid::ObjectId` as well

### Fixes

# 9.0.1
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ When running `cargo test`, the TypeScript bindings will be exported to the file
| chrono-impl | Implement `TS` for types from *chrono* |
| bigdecimal-impl | Implement `TS` for types from *bigdecimal* |
| url-impl | Implement `TS` for types from *url* |
| uuid-impl | Implement `TS` for types from *uuid* |
| bson-uuid-impl | Implement `TS` for types from *bson* |
| uuid-impl | Implement `TS` for types from *uuid*
| bson-uuid-impl | Implement `TS` for *bson::oid::ObjectId* and *bson::uuid* |
| bytes-impl | Implement `TS` for types from *bytes* |
| indexmap-impl | Implement `TS` for types from *indexmap* |
| ordered-float-impl | Implement `TS` for types from *ordered_float* |
Expand Down
7 changes: 5 additions & 2 deletions ts-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@
//! | chrono-impl | Implement `TS` for types from *chrono* |
//! | bigdecimal-impl | Implement `TS` for types from *bigdecimal* |
//! | url-impl | Implement `TS` for types from *url* |
//! | uuid-impl | Implement `TS` for types from *uuid* |
//! | bson-uuid-impl | Implement `TS` for types from *bson* |
//! | uuid-impl | Implement `TS` for types from *uuid*
//! | bson-uuid-impl | Implement `TS` for *bson::oid::ObjectId* and *bson::uuid* |
//! | bytes-impl | Implement `TS` for types from *bytes* |
//! | indexmap-impl | Implement `TS` for types from *indexmap* |
//! | ordered-float-impl | Implement `TS` for types from *ordered_float* |
Expand Down Expand Up @@ -1006,6 +1006,9 @@ impl_primitives! { ordered_float::OrderedFloat<f32> => "number" }
#[cfg(feature = "ordered-float-impl")]
impl_primitives! { ordered_float::OrderedFloat<f64> => "number" }

#[cfg(feature = "bson-uuid-impl")]
impl_primitives! { bson::oid::ObjectId => "string" }

#[cfg(feature = "bson-uuid-impl")]
impl_primitives! { bson::Uuid => "string" }

Expand Down
16 changes: 16 additions & 0 deletions ts-rs/tests/integration/bson.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#![cfg(feature = "bson-uuid-impl")]

use bson::{oid::ObjectId, Uuid};
use ts_rs::TS;

#[derive(TS)]
#[ts(export, export_to = "bson/")]
struct User {
_id: ObjectId,
_uuid: Uuid,
}

#[test]
fn bson() {
assert_eq!(User::decl(), "type User = { _id: string, _uuid: string, };")
}
1 change: 1 addition & 0 deletions ts-rs/tests/integration/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

mod arrays;
mod bound;
mod bson;
mod chrono;
mod concrete_generic;
mod docs;
Expand Down

0 comments on commit e268437

Please sign in to comment.