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

fix(caching): Exposes methods for accessing the inner client #81

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion crates/wasm-pkg-client/src/caching/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,20 @@ impl<T: Cache> CachingClient<T> {
})
}

fn client(&self) -> Result<&Client, Error> {
/// Returns a reference to the underlying client. Returns an error if the client is in read-only
/// mode.
///
/// Please note that using the client directly will bypass the cache.
pub fn client(&self) -> Result<&Client, Error> {
self.client
.as_ref()
.ok_or_else(|| Error::CacheError(anyhow::anyhow!("Client is in read only mode")))
}

/// Consumes the caching client and returns the underlying client. Returns an error if the
/// client is in read-only mode.
pub fn into_client(self) -> Result<Client, Error> {
self.client
.ok_or_else(|| Error::CacheError(anyhow::anyhow!("Client is in read only mode")))
}
}