Struct cyfs_bdt::ndn::chunk::ChunkManager
source · pub struct ChunkManager { /* private fields */ }Implementations§
source§impl ChunkManager
impl ChunkManager
sourcepub fn store(&self) -> &dyn ChunkReader
pub fn store(&self) -> &dyn ChunkReader
Examples found in repository?
examples/channel.rs (line 10)
8 9 10 11 12 13 14 15 16 17 18 19 20
async fn watch_recv_chunk(stack: StackGuard, chunkid: ChunkId) -> BuckyResult<ChunkId> {
loop {
let ret = stack.ndn().chunk_manager().store().get(&chunkid).await;
if let Ok(mut reader) = ret {
let mut content = vec![0u8; chunkid.len()];
let _ = reader.read(content.as_mut_slice()).await?;
let recv_id = ChunkId::calculate(content.as_slice()).await?;
return Ok(recv_id);
} else {
task::sleep(Duration::from_millis(500)).await;
}
}
}More examples
examples/double_source.rs (line 10)
8 9 10 11 12 13 14 15 16 17 18 19 20
async fn watch_recv_chunk(stack: StackGuard, chunkid: ChunkId) -> BuckyResult<ChunkId> {
loop {
let ret = stack.ndn().chunk_manager().store().get(&chunkid).await;
if let Ok(mut reader) = ret {
let mut content = vec![0u8; chunkid.len()];
let _ = reader.read(content.as_mut_slice()).await?;
let recv_id = ChunkId::calculate(content.as_slice()).await?;
return Ok(recv_id);
} else {
task::sleep(Duration::from_millis(500)).await;
}
}
}examples/upload_download.rs (line 13)
11 12 13 14 15 16 17 18 19 20 21 22 23
async fn watch_recv_chunk(stack: StackGuard, chunkid: ChunkId) -> BuckyResult<ChunkId> {
loop {
let ret = stack.ndn().chunk_manager().store().get(&chunkid).await;
if let Ok(mut reader) = ret {
let mut content = vec![0u8; chunkid.len()];
let _ = reader.read(content.as_mut_slice()).await?;
let recv_id = ChunkId::calculate(content.as_slice()).await?;
return Ok(recv_id);
} else {
task::sleep(Duration::from_millis(500)).await;
}
}
}examples/upload_from_path.rs (line 26)
24 25 26 27 28 29 30 31 32 33 34 35 36
async fn watch_recv_chunk(stack: StackGuard, chunkid: ChunkId) -> BuckyResult<ChunkId> {
loop {
let ret = stack.ndn().chunk_manager().store().get(&chunkid).await;
if let Ok(mut reader) = ret {
let mut content = vec![0u8; chunkid.len()];
let _ = reader.read(content.as_mut_slice()).await?;
let recv_id = ChunkId::calculate(content.as_slice()).await?;
return Ok(recv_id);
} else {
task::sleep(Duration::from_millis(500)).await;
}
}
}