pub struct History<'a> { /* private fields */ }Expand description
Append-only handle to a chat-history buffer.
Wraps &mut Vec<Message> but exposes only append
and view. Nothing can reach the underlying Vec to
call pop, truncate, clear, split_off, remove, or last_mut
without going through the explicit (and reviewable) escape hatch
Session::messages_mut_unchecked — which
intentionally does not exist in Phase A.
§Examples
use codetether_agent::provider::{ContentPart, Message, Role};
use codetether_agent::session::history::History;
let mut buf: Vec<Message> = Vec::new();
let mut history = History::new(&mut buf);
assert!(history.view().is_empty());
history.append(Message {
role: Role::Assistant,
content: vec![ContentPart::Text {
text: "ok".to_string(),
}],
});
assert_eq!(history.view().len(), 1);Implementations§
Source§impl<'a> History<'a>
impl<'a> History<'a>
Sourcepub fn new(buf: &'a mut Vec<Message>) -> Self
pub fn new(buf: &'a mut Vec<Message>) -> Self
Wrap an existing Vec<Message> as an append-only history.
§Arguments
buf— The underlying buffer. Ownership is not taken; the caller keeps theVecbut loses the ability to rewrite it while theHistoryhandle is alive.
§Examples
use codetether_agent::provider::Message;
use codetether_agent::session::history::History;
let mut buf: Vec<Message> = Vec::new();
let history = History::new(&mut buf);
assert!(history.view().is_empty());Auto Trait Implementations§
impl<'a> Freeze for History<'a>
impl<'a> RefUnwindSafe for History<'a>
impl<'a> Send for History<'a>
impl<'a> Sync for History<'a>
impl<'a> Unpin for History<'a>
impl<'a> UnsafeUnpin for History<'a>
impl<'a> !UnwindSafe for History<'a>
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::RequestSource§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,
Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
Apply a transformation to the response body. Read more
Source§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
High level tracing that classifies responses using HTTP status codes. Read more
Source§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
High level tracing that classifies responses using gRPC headers. Read more