1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use std::pin::Pin;

use cid::Cid;
use noosphere_core::data::{Did, MemoIpld};
use tokio::io::AsyncRead;

/// A descriptor for contents that is stored in a sphere.
pub struct SphereFile<C> {
    pub sphere_identity: Did,
    pub sphere_version: Cid,
    pub memo_version: Cid,
    pub memo: MemoIpld,
    pub contents: C,
}

impl<C> SphereFile<C>
where
    C: AsyncRead + 'static,
{
    pub fn boxed(self) -> SphereFile<Pin<Box<dyn AsyncRead + 'static>>> {
        SphereFile {
            sphere_identity: self.sphere_identity,
            sphere_version: self.sphere_version,
            memo_version: self.memo_version,
            memo: self.memo,
            contents: Box::pin(self.contents),
        }
    }
}