ensure blobstore's ValueOut implements AsRef<[u8]>

Summary:
Just like the previous diff with bookmarks, every user needs this and it makes
sense anyway.

Reviewed By: jsgf

Differential Revision: D5847877

fbshipit-source-id: b91a49e94da2d7e207061b6c52b78c55a2229dec
This commit is contained in:
Siddharth Agarwal 2017-09-18 00:22:06 -07:00 committed by Facebook Github Bot
parent 81f2ac473b
commit 482153dff8
8 changed files with 8 additions and 21 deletions

View File

@ -51,7 +51,6 @@ impl BlobChangeset {
pub fn load<B>(blobstore: &B, nodeid: &NodeHash) -> BoxFuture<Option<Self>, Error>
where
B: Blobstore<Key = String>,
B::ValueOut: AsRef<[u8]>,
{
let nodeid = *nodeid;
let key = cskey(&nodeid);

View File

@ -33,7 +33,6 @@ pub fn fetch_file_blob_from_blobstore<B>(
) -> BoxFuture<Vec<u8>, Error>
where
B: Blobstore<Key = String> + Clone,
B::ValueOut: AsRef<[u8]>,
{
get_node(&blobstore, nodeid)
.and_then({
@ -56,7 +55,6 @@ where
impl<B> BlobEntry<B>
where
B: Blobstore<Key = String> + Sync + Clone,
B::ValueOut: AsRef<[u8]>,
{
pub fn new(blobstore: B, path: Path, nodeid: NodeHash, ty: Type) -> Self {
Self {
@ -97,7 +95,6 @@ where
impl<B> Entry for BlobEntry<B>
where
B: Blobstore<Key = String> + Sync + Clone,
B::ValueOut: AsRef<[u8]>,
{
type Error = Error;

View File

@ -29,7 +29,6 @@ pub struct BlobManifest<B> {
impl<B> BlobManifest<B>
where
B: Blobstore<Key = String> + Clone,
B::ValueOut: AsRef<[u8]>,
{
pub fn load(blobstore: &B, manifestid: &NodeHash) -> BoxFuture<Option<Self>, Error> {
get_node(blobstore, manifestid.clone())
@ -61,7 +60,6 @@ where
impl<B> Manifest for BlobManifest<B>
where
B: Blobstore<Key = String> + Sync + Clone,
B::ValueOut: AsRef<[u8]> + Send,
{
type Error = Error;

View File

@ -48,7 +48,6 @@ impl<Head, Book, Blob> BlobRepo<Head, Book, Blob> {
impl<Head, Book, Blob> BlobRepo<Head, Book, Blob>
where
Blob: Blobstore<Key = String> + Clone + Sync,
Blob::ValueOut: AsRef<[u8]> + Send,
{
pub fn get_file_blob(&self, key: &NodeHash) -> BoxFuture<Vec<u8>, Error> {
fetch_file_blob_from_blobstore(self.inner.blobstore.clone(), *key)
@ -60,7 +59,6 @@ where
Head: Heads<Key = NodeHash> + Sync,
Book: Bookmarks<Value = NodeHash> + Sync,
Blob: Blobstore<Key = String> + Clone + Sync,
Blob::ValueOut: AsRef<[u8]> + Send,
{
type Error = Error;
@ -128,7 +126,6 @@ where
Head: Heads<Key = NodeHash> + Sync,
Book: Bookmarks + Sync,
Blob: Blobstore<Key = String> + Clone + Sync,
Blob::ValueOut: AsRef<[u8]> + Send,
{
repo: BlobRepo<Head, Book, Blob>,
seen: HashSet<NodeHash>,
@ -146,7 +143,6 @@ where
Head: Heads<Key = NodeHash> + Sync,
Book: Bookmarks<Value = NodeHash> + Sync,
Blob: Blobstore<Key = String> + Clone + Sync,
Blob::ValueOut: AsRef<[u8]>,
{
type Item = NodeHash;
type Error = Error;

View File

@ -24,7 +24,6 @@ pub struct RawNodeBlob {
pub fn get_node<B>(blobstore: &B, nodeid: NodeHash) -> BoxFuture<RawNodeBlob, Error>
where
B: Blobstore<Key = String>,
B::ValueOut: AsRef<[u8]>,
{
let key = format!("node-{}.bincode", nodeid);

View File

@ -48,7 +48,7 @@ where
B::PutBlob: Send + 'static,
B::ValueIn: From<Vi>,
Vi: Send + 'static,
Vo: From<B::ValueOut> + Send + 'static,
Vo: From<B::ValueOut> + AsRef<[u8]> + Send + 'static,
E: error::Error + From<B::Error> + Send + 'static,
{
let new = BlobstoreInner {
@ -66,7 +66,7 @@ where
B::PutBlob: Send + 'static,
B::ValueIn: From<Vi>,
Vi: Send + 'static,
Vo: From<B::ValueOut> + Send + 'static,
Vo: From<B::ValueOut> + AsRef<[u8]> + Send + 'static,
E: error::Error + From<B::Error> + Send + 'static,
{
let new = BlobstoreInner {
@ -96,7 +96,7 @@ where
B::PutBlob: Send + 'static,
B::ValueIn: From<Vi>,
Vi: Send + 'static,
Vo: From<B::ValueOut> + Send + 'static,
Vo: From<B::ValueOut> + AsRef<[u8]> + Send + 'static,
E: error::Error + From<B::Error> + Send + 'static,
{
type Error = E;

View File

@ -81,7 +81,7 @@ pub use boxed::{ArcBlobstore, BoxBlobstore};
pub trait Blobstore: Send + 'static {
type Key: Send + 'static;
type ValueIn: Send + 'static;
type ValueOut: Send + 'static;
type ValueOut: AsRef<[u8]> + Send + 'static;
type Error: error::Error + Send + 'static;
type GetBlob: Future<Item = Option<Self::ValueOut>, Error = Self::Error> + Send + 'static;
@ -96,7 +96,7 @@ pub trait Blobstore: Send + 'static {
Self::Key: Sized,
Self::ValueIn: From<Vi>,
Vi: Send + 'static,
Vo: From<Self::ValueOut> + Send + 'static,
Vo: From<Self::ValueOut> + AsRef<[u8]> + Send + 'static,
E: error::Error + From<Self::Error> + Send + 'static,
{
boxed::boxed(self)
@ -108,7 +108,7 @@ pub trait Blobstore: Send + 'static {
Self::Key: Sized,
Self::ValueIn: From<Vi>,
Vi: Send + 'static,
Vo: From<Self::ValueOut> + Send + 'static,
Vo: From<Self::ValueOut> + AsRef<[u8]> + Send + 'static,
E: error::Error + From<Self::Error> + Send + 'static,
{
boxed::arced(self)
@ -123,7 +123,7 @@ impl<K, Vi, Vo, E, GB, PB> Blobstore
where
K: Send + 'static,
Vi: Send + 'static,
Vo: Send + 'static,
Vo: AsRef<[u8]> + Send + 'static,
E: error::Error + Send + 'static,
GB: Future<Item = Option<Vo>, Error = E> + Send + 'static,
PB: Future<Item = (), Error = E> + Send + 'static,
@ -149,7 +149,7 @@ impl<K, Vi, Vo, E, GB, PB> Blobstore
where
K: Send + 'static,
Vi: Send + 'static,
Vo: Send + 'static,
Vo: AsRef<[u8]> + Send + 'static,
E: error::Error + Send + 'static,
GB: Future<Item = Option<Vo>, Error = E> + Send + 'static,
PB: Future<Item = (), Error = E> + Send + 'static,

View File

@ -162,7 +162,6 @@ impl<Head, Book, Blob> EdenServer<Head, Book, Blob>
where
EdenServer<Head, Book, Blob>: Service,
Blob: blobstore::Blobstore<Key = String> + Clone + Sync,
Blob::ValueOut: AsRef<[u8]> + Send,
Book: Bookmarks<Value = NodeHash> + Sync,
Head: Heads<Key = NodeHash> + Sync,
{
@ -237,7 +236,6 @@ where
Head: Heads<Key = NodeHash> + Sync,
Book: Bookmarks<Value = NodeHash> + Sync,
Blob: Blobstore<Key = String> + Clone + Sync,
Blob::ValueOut: AsRef<[u8]> + Send,
{
type Request = Request;
type Response = Response;