pub struct BackendDescriptor {
pub id: BackendId,
pub locality: Locality,
pub providers: Vec<String>,
pub frame: CoordFrame,
pub price: Option<PriceRef>,
pub manifest: Option<String>,
pub limits: InputLimits,
pub token_estimate: Option<TokenEstimate>,
pub concepts_per_request: Option<u32>,
}Expand description
What a backend is, where it runs, the frame it answers in, what it costs and what it takes.
§Example
use adk_vision::{BackendDescriptor, CoordFrame, InputLimits, Letterbox, Locality};
let rf_detr = BackendDescriptor::new(
"rf-detr-m",
Locality::InProcess,
CoordFrame::ModelInput { width: 576, height: 576, letterbox: Letterbox::Center },
)
.with_manifest("rf-detr-m");
assert!(!rf_detr.locality.is_remote());
assert!(rf_detr.price.is_none());Fields§
§id: BackendIdThe backend’s identifier.
locality: LocalityWhere it runs.
providers: Vec<String>The providers a remote backend sends to, by the id their responses carry in
LlmResponse::provider (anthropic, gemini, bedrock), which provider egress
rules match; empty when unknown.
frame: CoordFrameThe coordinate frame its regions are in.
price: Option<PriceRef>How it is billed; None for local backends, which record units at zero cost.
manifest: Option<String>The model manifest entry it runs, for model-backed backends.
limits: InputLimitsThe largest image it takes.
token_estimate: Option<TokenEstimate>How a token-billed backend’s cost is estimated before its request, so the run’s budget can refuse it before any image leaves (spec 3.7 §7.9).
concepts_per_request: Option<u32>The most open-vocabulary concepts one request takes (sam-3.1 takes one), so a
call with more is held and metered as one request per that many concepts; None for
no limit.
Implementations§
Source§impl BackendDescriptor
impl BackendDescriptor
Sourcepub fn new(id: impl Into<String>, locality: Locality, frame: CoordFrame) -> Self
pub fn new(id: impl Into<String>, locality: Locality, frame: CoordFrame) -> Self
A descriptor with no price, no manifest and no input limit.
Sourcepub fn with_provider(self, provider: impl Into<String>) -> Self
pub fn with_provider(self, provider: impl Into<String>) -> Self
Names a provider the backend sends to, for provider egress rules.
§Example
use adk_vision::{BackendDescriptor, CoordFrame, Locality};
let sam = BackendDescriptor::new(
"sam-3.1",
Locality::Remote { hosts: vec!["api.meta.ai".into()] },
CoordFrame::SentPixels,
)
.with_provider("muse");
assert_eq!(sam.providers, ["muse"]);Sourcepub fn with_token_estimate(self, estimate: TokenEstimate) -> Self
pub fn with_token_estimate(self, estimate: TokenEstimate) -> Self
Sets the preflight estimate of a token-billed backend.
Sourcepub fn with_price(self, price: PriceRef) -> Self
pub fn with_price(self, price: PriceRef) -> Self
Sets the price.
Sourcepub fn with_manifest(self, manifest: impl Into<String>) -> Self
pub fn with_manifest(self, manifest: impl Into<String>) -> Self
Names the model manifest entry.
Sourcepub fn with_limits(self, limits: InputLimits) -> Self
pub fn with_limits(self, limits: InputLimits) -> Self
Sets the input limits.
Sourcepub fn with_concepts_per_request(self, concepts: u32) -> Self
pub fn with_concepts_per_request(self, concepts: u32) -> Self
Takes at most concepts open-vocabulary concepts per request.
Sourcepub fn requests_for(&self, concepts: usize, other_prompts: bool) -> u64
pub fn requests_for(&self, concepts: usize, other_prompts: bool) -> u64
The requests a call with concepts concepts and, separately, other prompts makes:
one per concepts_per_request concepts, and one for
the other prompts; always 1 for a backend with no limit.
§Example
use adk_vision::{BackendDescriptor, CoordFrame, Locality};
let sam = BackendDescriptor::new("sam-3.1", Locality::Remote { hosts: vec![] }, CoordFrame::SentPixels)
.with_concepts_per_request(1);
assert_eq!(sam.requests_for(5, false), 5);
assert_eq!(sam.requests_for(2, true), 3);Trait Implementations§
Source§impl Clone for BackendDescriptor
impl Clone for BackendDescriptor
Source§impl Debug for BackendDescriptor
impl Debug for BackendDescriptor
Source§impl<'de> Deserialize<'de> for BackendDescriptor
impl<'de> Deserialize<'de> for BackendDescriptor
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>,
Source§impl PartialEq for BackendDescriptor
impl PartialEq for BackendDescriptor
Source§impl Serialize for BackendDescriptor
impl Serialize for BackendDescriptor
impl StructuralPartialEq for BackendDescriptor
Auto Trait Implementations§
impl Forget for BackendDescriptor
impl Freeze for BackendDescriptor
impl Move for BackendDescriptor
impl RefUnwindSafe for BackendDescriptor
impl Send for BackendDescriptorwhere
RawVecInner: Send,
impl Sync for BackendDescriptorwhere
RawVecInner: Sync,
impl Unpin for BackendDescriptor
impl UnsafeUnpin for BackendDescriptorwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
impl UnwindSafe for BackendDescriptorwhere
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
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,
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.