Skip to content
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

Rust SDK: with_credentials -> with_token #2118

Merged
merged 4 commits into from
Jan 15, 2025
Merged

Rust SDK: with_credentials -> with_token #2118

merged 4 commits into from
Jan 15, 2025

Conversation

gefjon
Copy link
Contributor

@gefjon gefjon commented Jan 13, 2025

Description of Changes

See discussion on clockworklabs/com.clockworklabs.spacetimedbsdk#212

This PR replaces DbConnectionBuilder::with_credentials with ::with_token, which does not require an Identity as argument. It also amends our machinery for saving and loading credentials to and from disk to suit the new API.

API and ABI breaking changes

Yep!

Expected complexity level and risk

Testing

Describe any testing you've done, and any testing you'd like your reviewers to do,
so that you're confident that all the changes work as expected!

  • I believe automated tests to be sufficient.

See discussion on
clockworklabs/com.clockworklabs.spacetimedbsdk#212

This PR replaces `DbConnectionBuilder::with_credentials` with `::with_token`,
which does not require an `Identity` as argument.
It also amends our machinery for saving and loading credentials to and from disk
to suit the new API.
@gefjon gefjon added the api-break A PR that makes an API breaking change label Jan 13, 2025
@gefjon gefjon requested a review from cloutiertyler January 13, 2025 19:54
@gefjon gefjon requested a review from RReverser January 14, 2025 19:22
Copy link
Contributor

@RReverser RReverser left a comment

Choose a reason for hiding this comment

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

I'm not a fan of impl ToString since this accepts almost any type in Rust ecosystem (any type that implements Display), eg user can accidentally pass Some(true) as a token and it will be silently stringified, but it's up to you.

No concerns otherwise.

@gefjon
Copy link
Contributor Author

gefjon commented Jan 14, 2025

I'm not a fan of impl ToString since this accepts almost any type in Rust ecosystem (any type that implements Display), eg user can accidentally pass Some(true) as a token and it will be silently stringified, but it's up to you.

No concerns otherwise.

We use impl ToString elsewhere. I'm not aware of any other trait in std that means "string-like thing that can be converted to String."

@RReverser
Copy link
Contributor

We use impl ToString elsewhere. I'm not aware of any other trait in std that means "string-like thing that can be converted to String."

Literally impl Into<String> is much better IMO. It covers all the usual suspects - String, &str, Cow<str> etc.

@gefjon
Copy link
Contributor Author

gefjon commented Jan 14, 2025

Literally impl Into is much better IMO. It covers all the usual suspects - String, &str, Cow etc.

If you want to open a follow-up PR that changes all uses of impl ToString in DbConnectionBuilder, I will happily accept it.

@gefjon gefjon added this pull request to the merge queue Jan 14, 2025
Merged via the queue into master with commit 537faa4 Jan 15, 2025
7 of 8 checks passed
RReverser added a commit that referenced this pull request Jan 15, 2025
As discussed on #2118, ToString is overly generic because it includes any type that implements Display.

Instead, we only want to accept string-like types (whether owned or not), which is better covered by Into<String>.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-break A PR that makes an API breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants