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: Option<Arm>) -> Self
pub fn with_cohort(self, cohort: Option<Arm>) -> Self
Tags the usage this scanner produces with an output-savings arm (#895).
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 Freeze for Scanner
impl RefUnwindSafe for Scanner
impl Send for Scanner
impl Sync for Scanner
impl Unpin for Scanner
impl UnsafeUnpin for Scanner
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
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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