Skip to content

RUST-1992 Update the driver for bson cstr API changes #1412

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

abr-egn
Copy link
Contributor

@abr-egn abr-egn commented Jul 8, 2025

RUST-1992

This involved unwinding all the fallibility I'd introduced in #1401, and introducing a compatibility layer for CStr that redirects to plain str for bson 2.x.

Cargo.toml Outdated
@@ -136,6 +136,9 @@ version = "3.0.0"
optional = true
features = ["serde"]

[patch."https://github.com/mongodb/bson-rust"]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll remove this once mongodb/bson-rust#571 is merged.

@@ -320,10 +320,11 @@ impl Client {
.and_then(|s| s.transaction.pinned_mongos())
.or_else(|| op.selection_criteria());

let op_name: &str = op.name().into();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

op.name().as_str() would be the easier way to spell this but unfortunately that doesn't compile for bson 2.x when op.name() is a str itself because str::as_str isn't stabilized yet 😞 (rust-lang/rust#130366)

@@ -108,7 +109,7 @@ pub(crate) trait Operation {
type O;

/// The name of the server side command associated with this operation.
const NAME: &'static str;
const NAME: &'static CStr;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the large majority of cases, NAME is primarily used as a key in rawdoc! construction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant