File tree Expand file tree Collapse file tree 7 files changed +59
-1
lines changed
Expand file tree Collapse file tree 7 files changed +59
-1
lines changed Original file line number Diff line number Diff line change 1+ pub ( crate ) trait RawDocumentBufExt {
2+ fn append_ref < ' a > (
3+ & mut self ,
4+ key : impl AsRef < str > ,
5+ value : impl Into < crate :: bson:: raw:: RawBsonRef < ' a > > ,
6+ ) ;
7+ }
8+
9+ impl RawDocumentBufExt for crate :: bson:: RawDocumentBuf {
10+ fn append_ref < ' a > (
11+ & mut self ,
12+ key : impl AsRef < str > ,
13+ value : impl Into < crate :: bson:: raw:: RawBsonRef < ' a > > ,
14+ ) {
15+ self . append ( key, value)
16+ }
17+ }
Original file line number Diff line number Diff line change @@ -22,6 +22,9 @@ use crate::{
2222 runtime:: SyncLittleEndianRead ,
2323} ;
2424
25+ #[ cfg( feature = "bson-3" ) ]
26+ use crate :: bson_compat:: RawDocumentBufExt as _;
27+
2528/// Coerce numeric types into an `i64` if it would be lossless to do so. If this Bson is not numeric
2629/// or the conversion would be lossy (e.g. 1.5 -> 1), this returns `None`.
2730#[ allow( clippy:: cast_possible_truncation) ]
Original file line number Diff line number Diff line change @@ -121,6 +121,17 @@ impl From<&OsMetadata> for RawBson {
121121 }
122122}
123123
124+ #[ cfg( feature = "bson-3" ) ]
125+ impl crate :: bson:: raw:: BindRawBsonRef for & OsMetadata {
126+ fn bind < F , R > ( self , f : F ) -> R
127+ where
128+ F : for < ' a > FnOnce ( bson3:: RawBsonRef < ' a > ) -> R ,
129+ {
130+ let raw: RawBson = self . into ( ) ;
131+ raw. bind ( f)
132+ }
133+ }
134+
124135impl From < & RuntimeEnvironment > for RawBson {
125136 fn from ( env : & RuntimeEnvironment ) -> Self {
126137 let RuntimeEnvironment {
@@ -158,6 +169,17 @@ impl From<&RuntimeEnvironment> for RawBson {
158169 }
159170}
160171
172+ #[ cfg( feature = "bson-3" ) ]
173+ impl crate :: bson:: raw:: BindRawBsonRef for & RuntimeEnvironment {
174+ fn bind < F , R > ( self , f : F ) -> R
175+ where
176+ F : for < ' a > FnOnce ( bson3:: RawBsonRef < ' a > ) -> R ,
177+ {
178+ let raw: RawBson = self . into ( ) ;
179+ raw. bind ( f)
180+ }
181+ }
182+
161183impl RuntimeEnvironment {
162184 pub ( crate ) const UNSET : Self = RuntimeEnvironment {
163185 name : None ,
Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ pub mod options;
2121pub use :: mongocrypt;
2222
2323pub mod action;
24+ #[ cfg( feature = "bson-3" ) ]
25+ pub ( crate ) mod bson_compat;
2426mod bson_util;
2527pub mod change_stream;
2628pub ( crate ) mod checked;
Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ use crate::{
1313
1414use super :: ExecutionContext ;
1515
16+ #[ cfg( feature = "bson-3" ) ]
17+ use crate :: bson_compat:: RawDocumentBufExt as _;
18+
1619#[ derive( Clone , Debug ) ]
1720pub ( crate ) enum UpdateOrReplace {
1821 UpdateModifications ( UpdateModifications ) ,
Original file line number Diff line number Diff line change @@ -111,6 +111,17 @@ impl From<TopologyVersion> for RawBson {
111111 }
112112}
113113
114+ #[ cfg( feature = "bson-3" ) ]
115+ impl crate :: bson:: raw:: BindRawBsonRef for TopologyVersion {
116+ fn bind < F , R > ( self , f : F ) -> R
117+ where
118+ F : for < ' a > FnOnce ( bson3:: RawBsonRef < ' a > ) -> R ,
119+ {
120+ let raw: RawBson = self . into ( ) ;
121+ raw. bind ( f)
122+ }
123+ }
124+
114125/// A description of the most up-to-date information known about a server.
115126#[ derive( Debug , Clone , Serialize ) ]
116127pub ( crate ) struct ServerDescription {
You can’t perform that action at this time.
0 commit comments