mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 16:57:49 +03:00
mercurial_types: make envelope functions use generics instead of trait objects
Summary: Make these functions generic so that callers don't need to construct a trait object whenever they want to call them. Passing in a trait object should still work so existing callsites should not be affected. Reviewed By: krallin Differential Revision: D20225830 fbshipit-source-id: df0389b0f19aa44aaa89682198f43cb9f1d84b25
This commit is contained in:
parent
f8d0ad25a2
commit
78adda0589
@ -78,9 +78,9 @@ impl ManifestContent {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn fetch_raw_manifest_bytes(
|
||||
pub fn fetch_raw_manifest_bytes<B: Blobstore>(
|
||||
ctx: CoreContext,
|
||||
blobstore: &Arc<dyn Blobstore>,
|
||||
blobstore: &B,
|
||||
manifest_id: HgManifestId,
|
||||
) -> BoxFuture<HgBlob, Error> {
|
||||
fetch_manifest_envelope(ctx, blobstore, manifest_id)
|
||||
@ -92,9 +92,9 @@ pub fn fetch_raw_manifest_bytes(
|
||||
.boxify()
|
||||
}
|
||||
|
||||
pub fn fetch_manifest_envelope(
|
||||
pub fn fetch_manifest_envelope<B: Blobstore>(
|
||||
ctx: CoreContext,
|
||||
blobstore: &Arc<dyn Blobstore>,
|
||||
blobstore: &B,
|
||||
manifest_id: HgManifestId,
|
||||
) -> impl Future<Item = HgManifestEnvelope, Error = Error> {
|
||||
fetch_manifest_envelope_opt(ctx, blobstore, manifest_id)
|
||||
@ -109,9 +109,9 @@ pub fn fetch_manifest_envelope(
|
||||
}
|
||||
|
||||
/// Like `fetch_manifest_envelope`, but returns None if the manifest wasn't found.
|
||||
pub fn fetch_manifest_envelope_opt(
|
||||
pub fn fetch_manifest_envelope_opt<B: Blobstore>(
|
||||
ctx: CoreContext,
|
||||
blobstore: &Arc<dyn Blobstore>,
|
||||
blobstore: &B,
|
||||
node_id: HgManifestId,
|
||||
) -> impl Future<Item = Option<HgManifestEnvelope>, Error = Error> {
|
||||
let blobstore_key = node_id.blobstore_key();
|
||||
|
@ -5,9 +5,6 @@
|
||||
* GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use blobstore::Blobstore;
|
||||
use bytes::Bytes;
|
||||
use futures::compat::Future01CompatExt;
|
||||
use mercurial_types::{
|
||||
@ -35,8 +32,8 @@ impl HgTreeContext {
|
||||
manifest_id: HgManifestId,
|
||||
) -> Result<Self, MononokeError> {
|
||||
let ctx = repo.ctx().clone();
|
||||
let blobstore: Arc<dyn Blobstore> = Arc::new(repo.blob_repo().blobstore().clone());
|
||||
let envelope = fetch_manifest_envelope(ctx, &blobstore, manifest_id)
|
||||
let blobstore = repo.blob_repo().blobstore();
|
||||
let envelope = fetch_manifest_envelope(ctx, blobstore, manifest_id)
|
||||
.compat()
|
||||
.await?;
|
||||
Ok(Self { repo, envelope })
|
||||
@ -47,8 +44,8 @@ impl HgTreeContext {
|
||||
manifest_id: HgManifestId,
|
||||
) -> Result<Option<Self>, MononokeError> {
|
||||
let ctx = repo.ctx().clone();
|
||||
let blobstore: Arc<dyn Blobstore> = Arc::new(repo.blob_repo().blobstore().clone());
|
||||
let envelope = fetch_manifest_envelope_opt(ctx, &blobstore, manifest_id)
|
||||
let blobstore = repo.blob_repo().blobstore();
|
||||
let envelope = fetch_manifest_envelope_opt(ctx, blobstore, manifest_id)
|
||||
.compat()
|
||||
.await?;
|
||||
Ok(envelope.map(move |envelope| Self { repo, envelope }))
|
||||
|
Loading…
Reference in New Issue
Block a user