Skip to main content

temporal_vision/
artifact.rs

1use crate::{ArtifactManifest, PixelDimensions};
2
3/// One deterministic encoded image held entirely in memory.
4#[derive(Clone, Debug, Eq, PartialEq)]
5pub struct EncodedImage {
6    dimensions: PixelDimensions,
7    bytes: Box<[u8]>,
8}
9
10impl EncodedImage {
11    pub(crate) fn new(dimensions: PixelDimensions, bytes: Vec<u8>) -> Self {
12        Self {
13            dimensions,
14            bytes: bytes.into_boxed_slice(),
15        }
16    }
17
18    pub const fn media_type(&self) -> &'static str {
19        "image/png"
20    }
21
22    pub const fn dimensions(&self) -> PixelDimensions {
23        self.dimensions
24    }
25
26    pub fn bytes(&self) -> &[u8] {
27        &self.bytes
28    }
29}
30
31/// Encoded artifact bytes and the provenance that describes those exact bytes.
32#[derive(Clone, Debug, PartialEq)]
33pub struct GeneratedArtifact<ArtifactId, FrameId, MarkerId, GapId> {
34    image: EncodedImage,
35    manifest: ArtifactManifest<ArtifactId, FrameId, MarkerId, GapId>,
36}
37
38impl<A, F, M, G> GeneratedArtifact<A, F, M, G> {
39    pub(crate) fn new(image: EncodedImage, manifest: ArtifactManifest<A, F, M, G>) -> Self {
40        Self { image, manifest }
41    }
42
43    pub const fn image(&self) -> &EncodedImage {
44        &self.image
45    }
46
47    pub const fn manifest(&self) -> &ArtifactManifest<A, F, M, G> {
48        &self.manifest
49    }
50}