Skip to content

Commit

Permalink
Fix lifetime of StoreTrait::update()
Browse files Browse the repository at this point in the history
  • Loading branch information
allada committed Oct 31, 2021
1 parent d8f218f commit 9ec43a2
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cas/grpc_service/tests/bytestream_server_test.rs
Expand Up @@ -239,7 +239,7 @@ pub mod read_tests {
raw_data[DATA_SIZE - 2] = 43u8;

let digest = DigestInfo::try_new(&HASH1, raw_data.len())?;
store.update(digest, Box::new(Cursor::new(raw_data.as_slice()))).await?;
store.update(digest, Box::new(Cursor::new(raw_data.clone()))).await?;

let read_request = ReadRequest {
resource_name: format!(
Expand Down
2 changes: 1 addition & 1 deletion cas/store/memory_store.rs
Expand Up @@ -40,7 +40,7 @@ impl StoreTrait for MemoryStore {
fn update<'a>(
self: std::pin::Pin<&'a Self>,
digest: DigestInfo,
mut reader: Box<dyn AsyncRead + Send + Sync + Unpin + 'a>,
mut reader: Box<dyn AsyncRead + Send + Sync + Unpin + 'static>,
) -> ResultFuture<'a, ()> {
Box::pin(async move {
let mut buffer = Vec::with_capacity(digest.size_bytes as usize);
Expand Down
2 changes: 1 addition & 1 deletion cas/store/store_trait.rs
Expand Up @@ -23,7 +23,7 @@ pub trait StoreTrait: Sync + Send + Unpin {
fn update<'a>(
self: Pin<&'a Self>,
digest: DigestInfo,
reader: Box<dyn AsyncRead + Send + Unpin + Sync + 'a>,
reader: Box<dyn AsyncRead + Send + Unpin + Sync + 'static>,
) -> ResultFuture<'a, ()>;

fn get_part<'a>(
Expand Down
6 changes: 3 additions & 3 deletions cas/store/tests/memory_store_test.rs
Expand Up @@ -117,17 +117,17 @@ mod memory_store_tests {
}
{
// .update() tests.
async fn update_should_fail<'a, 'b>(
async fn update_should_fail<'a>(
store: Pin<&'a MemoryStore>,
hash: &'a str,
expected_size: usize,
value: &'b str,
value: &'static str,
) {
let digest = DigestInfo::try_new(&hash, expected_size);
assert!(
digest.is_err()
|| store
.update(digest.unwrap(), Box::new(Cursor::new(&value)))
.update(digest.unwrap(), Box::new(Cursor::new(value)))
.await
.is_err(),
".has() should have failed: {} {} {}",
Expand Down
2 changes: 1 addition & 1 deletion cas/store/verify_store.rs
Expand Up @@ -92,7 +92,7 @@ impl StoreTrait for VerifyStore {
fn update<'a>(
self: std::pin::Pin<&'a Self>,
digest: DigestInfo,
reader: Box<dyn AsyncRead + Send + Sync + Unpin + 'a>,
reader: Box<dyn AsyncRead + Send + Sync + Unpin + 'static>,
) -> ResultFuture<'a, ()> {
let expected_size = digest.size_bytes;
Box::pin(async move {
Expand Down

0 comments on commit 9ec43a2

Please sign in to comment.