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

Merged
merged 8 commits into from
Jul 14, 2025

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.

@@ -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.

@abr-egn abr-egn marked this pull request as ready for review July 14, 2025 11:52
@abr-egn abr-egn requested a review from a team as a code owner July 14, 2025 11:52
@abr-egn abr-egn requested a review from isabelatkinson July 14, 2025 11:52
@abr-egn abr-egn merged commit a38c035 into mongodb:main Jul 14, 2025
18 checks passed
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.

2 participants