Skip to content

Commit

Permalink
Don't expose BoxFuture in public API
Browse files Browse the repository at this point in the history
`ObjectStore::get` calls itself recursively, so the returned future
needs to be boxed. However, this is an implementation detail, there's no
reason to expose it in the public API. Instead, we can move the
recursive call to a separate `get_impl` function that handles the
boxing, and `get` can just be a standard async function.
  • Loading branch information
oscarwcl authored and Jarema committed Dec 17, 2023
1 parent a4f303d commit cdb039b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions async-nats/src/jetstream/object_store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ impl ObjectStore {
/// # Ok(())
/// # }
/// ```
pub fn get<'bucket, 'future, T>(
pub async fn get<T: AsRef<str> + Send>(&self, object_name: T) -> Result<Object, GetError> {
self.get_impl(object_name).await
}

fn get_impl<'bucket, 'future, T>(
&'bucket self,
object_name: T,
) -> BoxFuture<'future, Result<Object, GetError>>
Expand All @@ -125,7 +129,7 @@ impl ObjectStore {
let link_name = link_name.clone();
debug!("getting object via link");
if link.bucket == self.name {
return self.get(link_name).await;
return self.get_impl(link_name).await;
} else {
let bucket = self
.stream
Expand All @@ -135,7 +139,7 @@ impl ObjectStore {
.map_err(|err| {
GetError::with_source(GetErrorKind::Other, err)
})?;
let object = bucket.get(&link_name).await?;
let object = bucket.get_impl(&link_name).await?;
return Ok(object);
}
} else {
Expand Down

0 comments on commit cdb039b

Please sign in to comment.