Skip to main content

EgressGate

Struct EgressGate 

Source
pub struct EgressGate { /* private fields */ }
Expand description

The only code that releases an image to a remote backend.

release runs six steps:

  1. Destination. Under the on-device profile (EgressConfig::on_device) every host is refused here; otherwise the adk-core EgressPolicy decides each of the backend’s hosts, and an unlisted host is refused here. private_networks = false (EgressConfig::private_networks) narrows that policy to public addresses.
  2. Minimise. The image is cropped to the request’s crop and downscaled to the backend’s limit; both are recorded in the transform chain.
  3. Redact. Every class the configuration lists, none by default, is found by its Redactor and filled with solid colour, then the caller’s marked regions. A listed class with no redactor refuses the release.
  4. Decide. The rule for the host or provider and the data class, else the default allow, says deny, ask or allow. ask holds the release unless a person approved this exact egress digest.
  5. Record. The receipt goes to the EgressRecorder before the image is returned; a recorder failure refuses the release.
  6. Release. The gate constructs the ReleasedImage.

Every refusal is recorded too. A frozen kill switch or a cancelled call refuses at the first step and again right before release.

Implementations§

Source§

impl EgressGate

Source

pub async fn release_clip( &self, cx: &VisionCx, request: ClipReleaseRequest<'_>, ) -> Result<ReleasedClip>

Releases a video clip to a remote backend, or refuses, in the steps of release:

  1. Destination. The on-device profile refuses every host; otherwise the adk-core egress policy decides each of the backend’s hosts.
  2. Minimise and redact. A clip is not re-encoded on the device, so a configuration that requires any redaction class refuses every clip (V-I2): send sampled frames instead, which the gate redacts one by one.
  3. Decide. The rule for the host and data class says deny, ask or allow; ask holds the clip unless a person approved its digest.
  4. Record and release. The receipt, with the clip’s digest as both source and egress digest, goes to the recorder and the audit log before the clip is returned.
§Errors

VisionError::EgressRefused at the destination, redact or decide step, VisionError::EgressHeld for a rule that asks, VisionError::Cancelled or the kill switch’s error, and the recorder’s error.

Source§

impl EgressGate

Source

pub fn new( policy: EgressPolicy, config: EgressConfig, recorder: Arc<dyn EgressRecorder>, ) -> Self

A gate with a destination policy, egress rules and a recorder.

Source

pub fn with_media_store(self, store: MediaStore) -> Self

Stores every egress copy as an artifact, under the call’s media scope, before it is released (spec 3.7 §7.8 step 5); the receipt and the audit record name it.

Source

pub fn has_released(&self, digest: &Digest) -> bool

Whether this gate released an image with egress digest digest: a part carrying a release annotation is trusted only when its bytes hash to a digest the gate released.

Source

pub fn redaction_classes(&self) -> Vec<RedactionClass>

The redaction classes the installed redactors find.

Source

pub fn decide( &self, backend: &BackendDescriptor, class: &DataClass, ) -> (EgressAction, Option<usize>)

The action and rule for an image of class bound for backend: the strictest over its hosts, deny over ask over allow, a provider rule matching each host of a backend that names that provider. The default for a backend on the device.

§Example
use std::sync::Arc;
use adk_core::egress::EgressPolicy;
use adk_vision::{
    BackendDescriptor, CoordFrame, DataClass, EgressAction, EgressConfig, EgressGate,
    InMemoryEgressRecorder, Locality,
};

let config = EgressConfig::default().with_provider_rule("anthropic", &[], EgressAction::Ask);
let gate = EgressGate::new(EgressPolicy::allow_private_networks(), config, Arc::new(InMemoryEgressRecorder::new()));
let claude = BackendDescriptor::new(
    "claude",
    Locality::Remote { hosts: vec!["gateway.example.com".into()] },
    CoordFrame::SentPixels,
);
let photo = DataClass::new("photo");
assert_eq!(gate.decide(&claude, &photo), (EgressAction::Allow, None));
assert_eq!(gate.decide(&claude.with_provider("anthropic"), &photo), (EgressAction::Ask, Some(0)));
Source

pub fn with_redactor(self, redactor: Arc<dyn Redactor>) -> Self

Installs a redactor.

Source

pub fn config(&self) -> &EgressConfig

The egress rules.

Source

pub async fn preview( &self, cx: &VisionCx, request: &ReleaseRequest<'_>, ) -> Result<EgressPreview>

Runs the destination, minimise and redact steps and returns what would leave, for an approval card. Records nothing unless it refuses.

§Errors

The refusals of release’s first three steps.

Source

pub async fn stage( &self, cx: &VisionCx, request: &ReleaseRequest<'_>, ) -> Result<StagedEgress>

Runs the destination, minimise and redact steps, stores the egress copy, and returns what would leave with the rule that applies, for an approval card (spec 3.7 S4).

Releases nothing. A rule that denies is refused here, and recorded, so nobody is asked about an image that can never leave.

§Errors

The refusals of release’s first three steps, VisionError::EgressRefused for a rule that denies, and the media store’s error.

Source

pub async fn release( &self, cx: &VisionCx, request: ReleaseRequest<'_>, ) -> Result<ReleasedImage>

Releases an image to a remote backend, or refuses.

§Errors

VisionError::EgressRefused at the destination or decide step, VisionError::InputTooLarge for an oversized image a backend refuses to have resized, VisionError::RedactionUnavailable, VisionError::EgressHeld for a rule that asks, VisionError::Cancelled or the kill switch’s error, and the recorder’s error.

Trait Implementations§

Source§

impl Debug for EgressGate

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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