pub struct Scanner { /* private fields */ }Expand description
Incrementally extracts RealUsage from a response stream (or a full body).
feed is called with raw response chunks and keeps only the trailing partial
line buffered (O(1) memory beyond one line); finalize returns the merged
usage once the stream ends.
Implementations§
Source§impl Scanner
impl Scanner
pub fn new(provider: Provider, url_model: Option<String>) -> Self
Sourcepub fn with_cohort(self, cohort: Cohorts) -> Self
pub fn with_cohort(self, cohort: Cohorts) -> Self
Tags the usage this scanner produces with its output and compression holdout arms.
Sourcepub fn with_wire_context(self, wire: Option<Box<WireContext>>) -> Self
pub fn with_wire_context(self, wire: Option<Box<WireContext>>) -> Self
Attaches the request-side gateway context (identity tags, wire savings, baseline inputs — enterprise#11/#17/#18) stamped onto the usage record.
Sourcepub fn with_header_cost(self, cost: Option<f64>) -> Self
pub fn with_header_cost(self, cost: Option<f64>) -> Self
Attaches a billed USD figure reported by the upstream via a response
header (LiteLLM x-litellm-response-cost, or the operator-configured
[proxy] cost_response_header, #1189). Applied at finalize only when
the body did not already carry a measured cost — a body figure
(OpenRouter usage.cost) is the bill itself and always wins.
Auto Trait Implementations§
impl Forget for Scanner
impl Freeze for Scannerwhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
*const WireContext is !null: Freeze,
PhantomData<WireContext>: Freeze,
impl Move for Scanner
impl RefUnwindSafe for Scanner
impl Send for Scanner
impl Sync for Scanner
impl Unpin for Scanner
impl UnsafeUnpin for Scannerwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const WireContext is !null: UnsafeUnpin,
PhantomData<WireContext>: UnsafeUnpin,
impl UnwindSafe for Scanner
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> 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 more