pub struct TranscriptReader;Expand description
Reads and reconstructs message history from JSONL transcript files.
TranscriptReader is a zero-size marker type with only associated functions.
Use TranscriptReader::load to reconstruct a message history from a .jsonl file,
TranscriptReader::load_meta to read the companion .meta.json sidecar, and
TranscriptReader::find_by_prefix to resolve a short ID prefix to a full UUID.
Implementations§
Source§impl TranscriptReader
impl TranscriptReader
Sourcepub fn load(path: &Path) -> Result<Vec<Message>, SubAgentError>
pub fn load(path: &Path) -> Result<Vec<Message>, SubAgentError>
Load all messages from a JSONL transcript file.
Malformed lines are skipped with a warning. An empty or missing file
returns an empty Vec. If the file does not exist at all but a matching
.meta.json sidecar exists, returns SubAgentError::Transcript with a
clear message so the caller knows the data is gone rather than silently
degrading to a fresh start.
§Errors
Returns SubAgentError::Transcript on unrecoverable I/O failures, or
when the transcript file is missing but meta exists (data-loss guard).
Sourcepub fn load_strict(path: &Path) -> Result<Vec<Message>, SubAgentError>
pub fn load_strict(path: &Path) -> Result<Vec<Message>, SubAgentError>
Load all messages from a JSONL transcript file, failing closed on the first skipped line.
Unlike load, which tolerates an unreadable or malformed line by skipping
it with a warning and returning the surviving entries as Ok, load_strict returns
SubAgentError::Transcript the moment any line would be skipped. Callers that must be
able to distinguish a genuinely complete trace from a partial one — e.g. tool-call
grounding, where a silently dropped ToolUse entry would misrepresent a partial read as
an authoritative “no tool ran” trace — should use this instead of load.
§Errors
Returns SubAgentError::Transcript if any line is unreadable or fails to parse, or if
the file is missing but a meta sidecar exists (data-loss guard, same as
load).
Sourcepub fn load_meta(
dir: &Path,
agent_id: &str,
) -> Result<TranscriptMeta, SubAgentError>
pub fn load_meta( dir: &Path, agent_id: &str, ) -> Result<TranscriptMeta, SubAgentError>
Load the meta sidecar for an agent.
§Errors
Returns SubAgentError::NotFound if the file does not exist,
SubAgentError::Transcript on parse failure.
Sourcepub fn find_by_prefix(dir: &Path, prefix: &str) -> Result<String, SubAgentError>
pub fn find_by_prefix(dir: &Path, prefix: &str) -> Result<String, SubAgentError>
Find the full agent ID by scanning dir for .meta.json files whose names
start with prefix.
§Errors
Returns SubAgentError::NotFound if no match is found,
SubAgentError::AmbiguousId if multiple matches are found,
SubAgentError::Transcript on I/O failure.
Auto Trait Implementations§
impl Freeze for TranscriptReader
impl RefUnwindSafe for TranscriptReader
impl Send for TranscriptReader
impl Sync for TranscriptReader
impl Unpin for TranscriptReader
impl UnsafeUnpin for TranscriptReader
impl UnwindSafe for TranscriptReader
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
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<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request