Skip to main content

FrameKeeper

Struct FrameKeeper 

Source
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

Source

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.

Source

pub fn with_policy(self, policy: RetentionPolicy) -> Self

Sets the retention policy.

Source

pub fn with_provenance(self, provenance: Provenance) -> Self

Sets the provenance kept frames record: Provenance::Screen or Provenance::Browser for those sources.

Source

pub fn policy(&self) -> &RetentionPolicy

The retention policy.

Source

pub async fn keep( &self, cx: &VisionCx, frame: &RedactedFrame, reason: KeepReason, ) -> Result<RetentionEntry>

Keeps frame for reason, now.

§Errors

As keep_at.

Source

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.

Source

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.

Source

pub async fn purge_expired( &self, cx: &VisionCx, now: DateTime<Utc>, ) -> Result<Vec<PurgedFrame>>

Deletes every frame whose retention ran out by now.

§Errors

As erase.

Source

pub async fn erase(&self, cx: &VisionCx) -> Result<Vec<PurgedFrame>>

Deletes every frame of the source in the scope: erasure by scope.

§Errors

The artifact service’s error, or the audit trail’s when it fails closed. Frames deleted before an error stay deleted and out of the index.

Trait Implementations§

Source§

impl Debug for FrameKeeper

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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
where Arc<dyn ArtifactService>: Send, RawVecInner: Send, Mutex<()>: Send,

§

impl Sync for FrameKeeper
where Arc<dyn ArtifactService>: Sync, RawVecInner: Sync, Mutex<()>: Sync,

§

impl Unpin for FrameKeeper
where Arc<dyn ArtifactService>: Unpin, *const u8 is !null: Unpin, Align4<u32>: Unpin, Align1<u8>: Unpin, *const Waiter is !null: Unpin, Align8<usize>: Unpin,

§

impl UnsafeUnpin for FrameKeeper
where *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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsAny for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Source§

fn type_name(&self) -> &'static str

Gets the type name of self
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast for T
where T: AsAny + ?Sized,

Source§

fn is<T>(&self) -> bool
where T: AsAny,

Returns true if the boxed type is the same as T. Read more
Source§

fn downcast_ref<T>(&self) -> Option<&T>
where T: AsAny,

Forward to the method defined on the type Any.
Source§

fn downcast_mut<T>(&mut self) -> Option<&mut T>
where T: AsAny,

Forward to the method defined on the type Any.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more