pub struct EgressConfig {
pub default: EgressAction,
pub redact: Vec<RedactionClass>,
pub rules: Vec<EgressRuleConfig>,
pub on_device: bool,
pub private_networks: bool,
}Expand description
The [egress] table: the default action, the redaction classes every release passes
through, and the rules per host or provider and data class.
With no table, every image a remote backend is called with leaves unredacted and
unasked, to a public or a private-network host. Each restriction is an opt-in:
default = "ask" or "deny", a rule that asks or denies for a host or provider, a
redact class, private_networks = false, or on_device = true. A chosen
restriction fails closed: a listed class no redactor covers refuses the release
(VisionError::RedactionUnavailable), and redaction runs before the decision, so an
approval names the redacted image. Unknown keys are refused rather than ignored (V-I2).
§Example
use adk_vision::{DataClass, EgressAction, VisionConfig};
let open = VisionConfig::default();
assert_eq!(open.egress.decide("api.anthropic.com", &[], &DataClass::new("photo")).0, EgressAction::Allow);
assert!(open.egress.redact.is_empty());
let config = VisionConfig::from_toml_str(r#"
[egress]
default = "ask"
redact = ["faces", "personal_text"]
[[egress.rule]]
host = "generativelanguage.googleapis.com"
classes = ["document_crop"]
action = "allow"
[[egress.rule]]
provider = "openrouter"
action = "deny"
"#).unwrap();
let (action, rule) = config
.egress
.decide("generativelanguage.googleapis.com", &[], &DataClass::new("document_crop"));
assert_eq!((action, rule), (EgressAction::Allow, Some(0)));
let photo = DataClass::new("photo");
assert_eq!(config.egress.decide("api.anthropic.com", &[], &photo).0, EgressAction::Ask);
let openrouter = ["openrouter".to_string()];
assert_eq!(config.egress.decide("openrouter.ai", &openrouter, &photo), (EgressAction::Deny, Some(1)));
assert!(VisionConfig::from_toml_str("[egress]\nallow_before_redaction = true").is_err());Fields§
§default: EgressActionThe action when no rule matches. allow by default; ask or deny opt in to a
restriction.
redact: Vec<RedactionClass>The redaction classes every release passes through; none by default.
rules: Vec<EgressRuleConfig>The rules, first match wins.
on_device: boolThe on-device profile: every remote destination is refused at the gate’s first step,
whatever the rules say, so no image leaves the machine. false by default.
private_networks: boolWhether images may go to a host on a loopback, private or link-local address, such as
a self-hosted model on this machine or the local network. true by default;
private_networks = false keeps image egress to public addresses. Cloud metadata
endpoints are refused either way, and the gate’s EgressPolicy
stays the ceiling: this switch only narrows it.
Implementations§
Source§impl EgressConfig
impl EgressConfig
Sourcepub fn public_networks_only(self) -> Self
pub fn public_networks_only(self) -> Self
Keeps image egress to public addresses: a host on a loopback, private or link-local address is refused at the destination step.
§Example
use adk_vision::{EgressConfig, VisionConfig};
assert!(EgressConfig::default().private_networks);
let config = VisionConfig::from_toml_str("[egress]\nprivate_networks = false").unwrap();
assert_eq!(config.egress, EgressConfig::default().public_networks_only());Sourcepub fn on_device(self) -> Self
pub fn on_device(self) -> Self
The on-device profile: every release is refused at the destination step with its reason, before anything is minimised, redacted or sent.
§Example
use adk_vision::{EgressConfig, VisionConfig};
let config = VisionConfig::from_toml_str("[egress]\non_device = true").unwrap();
assert_eq!(config.egress, EgressConfig::default().on_device());Sourcepub fn with_default(self, action: EgressAction) -> Self
pub fn with_default(self, action: EgressAction) -> Self
Sets the default action.
Sourcepub fn redacting(self, class: RedactionClass) -> Self
pub fn redacting(self, class: RedactionClass) -> Self
Requires a redaction class on every release.
Sourcepub fn with_rule(
self,
host: &str,
classes: &[&str],
action: EgressAction,
) -> Self
pub fn with_rule( self, host: &str, classes: &[&str], action: EgressAction, ) -> Self
Appends a rule for host, or *.example.com for its subdomains.
Sourcepub fn with_provider_rule(
self,
provider: &str,
classes: &[&str],
action: EgressAction,
) -> Self
pub fn with_provider_rule( self, provider: &str, classes: &[&str], action: EgressAction, ) -> Self
Appends a rule for every host of provider, a provider id such as anthropic.
§Example
use adk_vision::{DataClass, EgressAction, EgressConfig};
let config = EgressConfig::default().with_provider_rule("gemini", &[], EgressAction::Ask);
let gemini = ["gemini".to_string()];
let photo = DataClass::new("photo");
assert_eq!(config.decide("us-central1-aiplatform.googleapis.com", &gemini, &photo).0, EgressAction::Ask);
assert_eq!(config.decide("api.anthropic.com", &[], &photo).0, EgressAction::Allow);Trait Implementations§
Source§impl Clone for EgressConfig
impl Clone for EgressConfig
Source§impl Debug for EgressConfig
impl Debug for EgressConfig
Source§impl Default for EgressConfig
impl Default for EgressConfig
Source§impl<'de> Deserialize<'de> for EgressConfig
impl<'de> Deserialize<'de> for EgressConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for EgressConfig
Source§impl PartialEq for EgressConfig
impl PartialEq for EgressConfig
Source§impl Serialize for EgressConfig
impl Serialize for EgressConfig
impl StructuralPartialEq for EgressConfig
Auto Trait Implementations§
impl Forget for EgressConfig
impl Freeze for EgressConfigwhere
*const u8 is !null: Freeze,
PhantomData<RedactionClass>: Freeze,
PhantomData<EgressRuleConfig>: Freeze,
impl Move for EgressConfig
impl RefUnwindSafe for EgressConfig
impl Send for EgressConfigwhere
RawVecInner: Send,
impl Sync for EgressConfigwhere
RawVecInner: Sync,
impl Unpin for EgressConfig
impl UnsafeUnpin for EgressConfigwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<RedactionClass>: UnsafeUnpin,
PhantomData<EgressRuleConfig>: UnsafeUnpin,
impl UnwindSafe for EgressConfigwhere
RawVecInner: UnwindSafe,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Downcast for T
impl<T> Downcast for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().impl<T> Scalar for T
impl<T> Scalar for T
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.