pub struct FrameBudget {
pub local_fps: f32,
pub min_local_fps: f32,
pub local_frames_per_period: Option<u64>,
pub escalations_per_minute: Option<u32>,
pub escalated_frames_per_period: Option<u64>,
pub min_frames_per_escalation: u64,
pub period_secs: u64,
}Expand description
What a stream may spend: a local sampling rate, escalations per minute and frame quotas per period (spec 3.7 §7.9).
| Field | Caps |
|---|---|
local_fps, min_local_fps | The local rate, and the lowest rate the governor steps down to before it pauses the source |
local_frames_per_period | Frames processed locally per period |
escalations_per_minute | Escalation requests in any 60 seconds |
escalated_frames_per_period | Frames billed for escalations per period, each request at least min_frames_per_escalation |
period_secs | The quota period; periods are aligned to the Unix epoch, so a day starts at 00:00 UTC |
§Example
use adk_vision::stream::FrameBudget;
// S11: local detection at 5 fps, escalations to sam-3.1 video, a daily frame quota.
let budget = FrameBudget::new(5.0)
.with_min_local_fps(1.0)
.with_local_quota(200_000)
.with_escalations_per_minute(2)
.with_escalation_quota(5_000);
assert_eq!(budget.min_frames_per_escalation, 50);
assert_eq!(budget.period_secs, 86_400);
assert!(budget.validate().is_ok());Fields§
§local_fps: f32The local sampling rate, in frames a second.
min_local_fps: f32The lowest local rate the governor steps down to before it pauses the source.
local_frames_per_period: Option<u64>Frames processed locally per period; unlimited when unset.
escalations_per_minute: Option<u32>Escalation requests in any 60 seconds; unlimited when unset.
escalated_frames_per_period: Option<u64>Frames billed for escalations per period; unlimited when unset.
min_frames_per_escalation: u64The frames one escalation request is billed at least: 50 for sam-3.1 video.
period_secs: u64The quota period in seconds: 86,400, a day, by default.
Implementations§
Source§impl FrameBudget
impl FrameBudget
Sourcepub fn new(local_fps: f32) -> Self
pub fn new(local_fps: f32) -> Self
A budget of local_fps with no quotas, a floor of a tenth of that rate, the
sam-3.1 video minimum of 50 frames per escalation and a one-day period.
Sourcepub fn with_min_local_fps(self, fps: f32) -> Self
pub fn with_min_local_fps(self, fps: f32) -> Self
Sets the lowest local rate before a pause.
Sourcepub fn with_local_quota(self, frames: u64) -> Self
pub fn with_local_quota(self, frames: u64) -> Self
Caps the frames processed locally per period.
Sourcepub fn with_escalations_per_minute(self, requests: u32) -> Self
pub fn with_escalations_per_minute(self, requests: u32) -> Self
Caps escalation requests per minute.
Sourcepub fn with_escalation_quota(self, frames: u64) -> Self
pub fn with_escalation_quota(self, frames: u64) -> Self
Caps the frames billed for escalations per period.
Sourcepub fn with_min_frames_per_escalation(self, frames: u64) -> Self
pub fn with_min_frames_per_escalation(self, frames: u64) -> Self
Sets the billed minimum of one escalation request.
Sourcepub fn with_period_secs(self, secs: u64) -> Self
pub fn with_period_secs(self, secs: u64) -> Self
Sets the quota period.
Trait Implementations§
Source§impl Clone for FrameBudget
impl Clone for FrameBudget
Source§impl Debug for FrameBudget
impl Debug for FrameBudget
Source§impl<'de> Deserialize<'de> for FrameBudget
impl<'de> Deserialize<'de> for FrameBudget
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 FrameBudget
impl PartialEq for FrameBudget
Source§impl Serialize for FrameBudget
impl Serialize for FrameBudget
impl StructuralPartialEq for FrameBudget
Auto Trait Implementations§
impl Forget for FrameBudget
impl Freeze for FrameBudget
impl Move for FrameBudget
impl RefUnwindSafe for FrameBudget
impl Send for FrameBudget
impl Sync for FrameBudget
impl Unpin for FrameBudget
impl UnsafeUnpin for FrameBudget
impl UnwindSafe for FrameBudget
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.