pub struct FrameKeeper { /* private fields */ }Expand description
Stores the frames of one source that a wake, a card or a person keeps, and deletes them when their retention runs out (spec 3.7 §7.13, Q13).
Only a RedactedFrame can be kept, so every stored frame passed its privacy hook
before the write (V-I9, S18). Frames go to the media store as PNG, by digest, so a frame
kept for a wake and again for a card is one artifact with both reasons. The keeper’s
index is itself an artifact in the scope, vision-retention-<source>-<hash>.json, so a
restarted process still purges what an earlier one kept. Every keep writes
vision.evidence.kept, and every deletion vision.evidence.purged, with the frame’s
digest, never its pixels.
§Example
use std::sync::Arc;
use std::time::Duration;
use adk_artifact::InMemoryArtifactService;
use adk_vision::stream::{FrameKeeper, FramePrivacy, KeepReason, NoRedaction};
use adk_vision::{DecodedImage, Frame, FramePixels, FrameSourceId, MediaScope, VisionCx};
let source = FrameSourceId("line-1".into());
let keeper = FrameKeeper::new(
Arc::new(InMemoryArtifactService::new()),
MediaScope::new("inspector", "u1", "s1"),
source.clone(),
);
let frame = Frame {
source,
index: 7,
pts: Duration::from_millis(700),
captured_at: chrono::Utc::now(),
pixels: FramePixels::Ephemeral(Arc::new(DecodedImage::filled(8, 8, [40; 4]))),
};
let cx = VisionCx::new();
let redacted = FramePrivacy::new(Arc::new(NoRedaction)).apply(&cx, frame).await.unwrap();
let kept = keeper.keep(&cx, &redacted, KeepReason::WakePayload).await.unwrap();
assert_eq!(kept.reasons, vec![KeepReason::WakePayload]);
// Thirty days on, it is gone.
let later = kept.kept_at + chrono::TimeDelta::days(31);
assert_eq!(keeper.purge_expired(&cx, later).await.unwrap().len(), 1);Implementations§
Source§impl FrameKeeper
impl FrameKeeper
Sourcepub fn new(
artifacts: Arc<dyn ArtifactService>,
scope: MediaScope,
source: FrameSourceId,
) -> Self
pub fn new( artifacts: Arc<dyn ArtifactService>, scope: MediaScope, source: FrameSourceId, ) -> Self
A keeper of source’s frames in scope, with the default 30-day policy and camera
provenance.
Sourcepub fn with_policy(self, policy: RetentionPolicy) -> Self
pub fn with_policy(self, policy: RetentionPolicy) -> Self
Sets the retention policy.
Sourcepub fn with_provenance(self, provenance: Provenance) -> Self
pub fn with_provenance(self, provenance: Provenance) -> Self
Sets the provenance kept frames record: Provenance::Screen or
Provenance::Browser for those sources.
Sourcepub fn policy(&self) -> &RetentionPolicy
pub fn policy(&self) -> &RetentionPolicy
The retention policy.
Sourcepub async fn keep(
&self,
cx: &VisionCx,
frame: &RedactedFrame,
reason: KeepReason,
) -> Result<RetentionEntry>
pub async fn keep( &self, cx: &VisionCx, frame: &RedactedFrame, reason: KeepReason, ) -> Result<RetentionEntry>
Sourcepub async fn keep_at(
&self,
cx: &VisionCx,
frame: &RedactedFrame,
reason: KeepReason,
at: DateTime<Utc>,
) -> Result<RetentionEntry>
pub async fn keep_at( &self, cx: &VisionCx, frame: &RedactedFrame, reason: KeepReason, at: DateTime<Utc>, ) -> Result<RetentionEntry>
Keeps frame for reason as of at: stores it, records it in the index, and writes
vision.evidence.kept.
§Errors
VisionError::InvalidInput for a frame of another source, the encoder’s or the
artifact service’s error, or the audit trail’s when it fails closed.
Sourcepub async fn kept(&self) -> Result<Vec<RetentionEntry>>
pub async fn kept(&self) -> Result<Vec<RetentionEntry>>
Every frame kept and not yet purged.
§Errors
The artifact service’s error, or VisionError::Parse for an index that does not
parse.
Sourcepub async fn purge_expired(
&self,
cx: &VisionCx,
now: DateTime<Utc>,
) -> Result<Vec<PurgedFrame>>
pub async fn purge_expired( &self, cx: &VisionCx, now: DateTime<Utc>, ) -> Result<Vec<PurgedFrame>>
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for FrameKeeper
impl !RefUnwindSafe for FrameKeeper
impl !UnwindSafe for FrameKeeper
impl Forget for FrameKeeper
impl Move for FrameKeeper
impl Send for FrameKeeper
impl Sync for FrameKeeper
impl Unpin for FrameKeeper
impl UnsafeUnpin for FrameKeeperwhere
*const ArcInner<dyn ArtifactService> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn ArtifactService>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<Mutex<Waitlist>>: UnsafeUnpin,
Align1<u8>: UnsafeUnpin,
*const Waiter is !null: UnsafeUnpin,
Align8<usize>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for T
impl<T> Downcast for T
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
impl<T> MaybeSend for Twhere
T: Send,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.