pub struct MessageDelta {
pub delta: MessageDeltaPayload,
pub usage: Option<Usage>,
}Expand description
A delta update for the message, typically emitted at the end of the stream.
Carries the final StreamStopReason (why the model stopped) and
the cumulative Usage statistics for the entire request. Emitted
after all parts are complete but before MessageStop.
§Example
use loopctl::stream::{MessageDelta, MessageDeltaPayload, Usage};
let delta = MessageDelta {
delta: MessageDeltaPayload { stop_reason: Some("end_turn".to_string()) },
usage: Some(Usage::new(100, 50)),
};§Relationship to MessageDeltaPayload
The delta field contains the stop reason string,
while the usage field carries token counts. Together
they provide the final summary of the streaming response.
Fields§
§delta: MessageDeltaPayloadThe delta details containing the stop reason.
See MessageDeltaPayload for the payload structure. Use
StreamStopReason::from_api_str to parse the stop reason string
into a typed enum.
usage: Option<Usage>Token usage statistics for this request.
Some when the API reports usage; None if usage data
is not available or not yet received. See Usage.
Typically populated in the final MessageDelta event
and reflects cumulative token consumption for the entire request.
Trait Implementations§
Source§impl Clone for MessageDelta
impl Clone for MessageDelta
Source§fn clone(&self) -> MessageDelta
fn clone(&self) -> MessageDelta
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more