pub struct EgressGate { /* private fields */ }Expand description
The only code that releases an image to a remote backend.
release runs six steps:
- Destination. Under the on-device profile (
EgressConfig::on_device) every host is refused here; otherwise the adk-coreEgressPolicydecides 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. - Minimise. The image is cropped to the request’s crop and downscaled to the backend’s limit; both are recorded in the transform chain.
- Redact. Every class the configuration lists, none by default, is found by its
Redactorand filled with solid colour, then the caller’s marked regions. A listed class with no redactor refuses the release. - Decide. The rule for the host or provider and the data class, else the default
allow, saysdeny,askorallow.askholds the release unless a person approved this exact egress digest. - Record. The receipt goes to the
EgressRecorderbefore the image is returned; a recorder failure refuses the release. - 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
impl EgressGate
Sourcepub async fn release_clip(
&self,
cx: &VisionCx,
request: ClipReleaseRequest<'_>,
) -> Result<ReleasedClip>
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:
- Destination. The on-device profile refuses every host; otherwise the adk-core egress policy decides each of the backend’s hosts.
- 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.
- Decide. The rule for the host and data class says
deny,askorallow;askholds the clip unless a person approved its digest. - 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
impl EgressGate
Sourcepub fn new(
policy: EgressPolicy,
config: EgressConfig,
recorder: Arc<dyn EgressRecorder>,
) -> Self
pub fn new( policy: EgressPolicy, config: EgressConfig, recorder: Arc<dyn EgressRecorder>, ) -> Self
A gate with a destination policy, egress rules and a recorder.
Sourcepub fn with_media_store(self, store: MediaStore) -> Self
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.
Sourcepub fn has_released(&self, digest: &Digest) -> bool
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.
Sourcepub fn redaction_classes(&self) -> Vec<RedactionClass>
pub fn redaction_classes(&self) -> Vec<RedactionClass>
The redaction classes the installed redactors find.
Sourcepub fn decide(
&self,
backend: &BackendDescriptor,
class: &DataClass,
) -> (EgressAction, Option<usize>)
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)));Sourcepub fn with_redactor(self, redactor: Arc<dyn Redactor>) -> Self
pub fn with_redactor(self, redactor: Arc<dyn Redactor>) -> Self
Installs a redactor.
Sourcepub fn config(&self) -> &EgressConfig
pub fn config(&self) -> &EgressConfig
The egress rules.
Sourcepub async fn preview(
&self,
cx: &VisionCx,
request: &ReleaseRequest<'_>,
) -> Result<EgressPreview>
pub async fn preview( &self, cx: &VisionCx, request: &ReleaseRequest<'_>, ) -> Result<EgressPreview>
Sourcepub async fn stage(
&self,
cx: &VisionCx,
request: &ReleaseRequest<'_>,
) -> Result<StagedEgress>
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.
Sourcepub async fn release(
&self,
cx: &VisionCx,
request: ReleaseRequest<'_>,
) -> Result<ReleasedImage>
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§
Auto Trait Implementations§
impl !Freeze for EgressGate
impl !RefUnwindSafe for EgressGate
impl !UnwindSafe for EgressGate
impl Forget for EgressGate
impl Move for EgressGate
impl Send for EgressGate
impl Sync for EgressGate
impl Unpin for EgressGate
impl UnsafeUnpin for EgressGatewhere
*const u8 is !null: UnsafeUnpin,
PhantomData<RuleSet>: UnsafeUnpin,
PhantomData<RedactionClass>: UnsafeUnpin,
PhantomData<EgressRuleConfig>: UnsafeUnpin,
PhantomData<Arc<dyn Redactor>>: UnsafeUnpin,
*const ArcInner<dyn EgressRecorder> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn EgressRecorder>>: UnsafeUnpin,
*const ArcInner<dyn ArtifactService> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn ArtifactService>>: UnsafeUnpin,
Align4<u32>: UnsafeUnpin,
Align1<u8>: UnsafeUnpin,
PhantomData<(Digest, ())>: 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.