Skip to content

fix(storage): StorageImpl nameable outside crate#3683

Merged
dbolduc merged 2 commits intogoogleapis:mainfrom
dbolduc:fix-storage-nameable-stub-default
Nov 3, 2025
Merged

fix(storage): StorageImpl nameable outside crate#3683
dbolduc merged 2 commits intogoogleapis:mainfrom
dbolduc:fix-storage-nameable-stub-default

Conversation

@dbolduc
Copy link
Copy Markdown
Member

@dbolduc dbolduc commented Nov 3, 2025

Fixes #3663

Make the default stub implementation name-able from outside the crate. This lets applications provide a default implementation for their own generics.

Note that this type is not constructible from outside the crate. It has no public fields. Its only public fns are its impl of stub::Storage.

I think this type belongs in the stub module. I called it StorageImpl.

If we are happy with these names, I will clean up the internal wiring, either in this PR or in a follow up.

@product-auto-label product-auto-label bot added the api: storage Issues related to the Cloud Storage API. label Nov 3, 2025
@codecov
Copy link
Copy Markdown

codecov bot commented Nov 3, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.93%. Comparing base (b5203cd) to head (8d68598).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3683      +/-   ##
==========================================
+ Coverage   95.75%   95.93%   +0.18%     
==========================================
  Files         129      131       +2     
  Lines        5157     5197      +40     
==========================================
+ Hits         4938     4986      +48     
+ Misses        219      211       -8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
#[derive(Clone, Debug)]
pub struct Storage<S = crate::storage::transport::Storage>
pub struct Storage<S = crate::stub::StorageImpl>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe crate::stub::DefaultStorageStub ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks for the suggestion. I will go with crate::stub::DefaultStorage to not repeat "stub"

pub mod stub {
pub use crate::control::stub::*;
pub use crate::storage::stub::*;
pub use crate::storage::transport::Storage as StorageImpl;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This makes the type public, which means it goes into the documentation, and it current has no documentation. Luckily the constructor is pub(crate), so at least there are no new methods to document.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

and it currently has no documentation

This PR adds documentation.

image

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You help me realize that the pub mod stub did not have documentation. Sent #3690 for that.

pub mod streaming_source;
pub mod stub;
pub(crate) mod transport;
pub mod transport;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we need to make this change? It makes the module public and it would be only too easy to add a public symbol by accident in that module too?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Do we need to make this change?

Apparently not. Thanks for catching. Reverted.

It makes the module public

I didn't think so. It is within the non-public mod storage:

it would be only too easy to add a public symbol by accident in that module too?

We would have to accidentally export it too.

@dbolduc dbolduc marked this pull request as ready for review November 3, 2025 19:49
@dbolduc dbolduc requested a review from a team November 3, 2025 19:49
@dbolduc dbolduc merged commit c335380 into googleapis:main Nov 3, 2025
28 checks passed
@dbolduc dbolduc deleted the fix-storage-nameable-stub-default branch November 3, 2025 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: storage Issues related to the Cloud Storage API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

storage: template-based stub makes it hard to create a generic type holding a Storage

2 participants