pub struct DraftLifecycle<'a> { /* private fields */ }Expand description
The stateless lifecycle, folded over a trace’s message events in order.
use mcp_trace_validator::context::draft::{DraftLifecycle, DraftPhase};
use mcp_conformance_core::trace::TraceEvent;
// A stateless session: the first message is an ordinary request, with no handshake.
let events: Vec<TraceEvent> = serde_json::from_str::<Vec<_>>(r#"[
{"seq":0,"direction":"client-to-server","transport":"stdio","kind":"message",
"payload":{"jsonrpc":"2.0","id":1,"method":"tools/list"}}
]"#).unwrap();
let lifecycle = DraftLifecycle::new(&events);
// Operational immediately — no `initialize` required (contrast `2025-11-25`).
assert_eq!(lifecycle.phases()[0], DraftPhase::Active);
assert_eq!(lifecycle.final_phase(), DraftPhase::Active);
assert!(lifecycle.discover().request.is_none());Implementations§
Source§impl<'a> DraftLifecycle<'a>
impl<'a> DraftLifecycle<'a>
Sourcepub fn new(events: &'a [TraceEvent]) -> Self
pub fn new(events: &'a [TraceEvent]) -> Self
Folds the stateless lifecycle over events in one pass, recording the phase
before each event and the server/discover exchange.
Sourcepub fn phases(&self) -> &[DraftPhase]
pub fn phases(&self) -> &[DraftPhase]
The phase before each event, in trace order (one entry per event).
Sourcepub const fn final_phase(&self) -> DraftPhase
pub const fn final_phase(&self) -> DraftPhase
The lifecycle phase after the entire trace has been processed.
Sourcepub const fn discover(&self) -> &DiscoverExchange<'a>
pub const fn discover(&self) -> &DiscoverExchange<'a>
The observed server/discover exchange.
Sourcepub fn server_capabilities(&self) -> Option<&'a Value>
pub fn server_capabilities(&self) -> Option<&'a Value>
The server’s declared capabilities, from the server/discover result — the
stateless analogue of the initialize result’s capabilities. None when no
discovery completed (the client capability surface lives in each request’s _meta
in this revision, which is a per-request concern, not a lifecycle one).
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for DraftLifecycle<'a>
impl<'a> RefUnwindSafe for DraftLifecycle<'a>
impl<'a> Send for DraftLifecycle<'a>
impl<'a> Sync for DraftLifecycle<'a>
impl<'a> Unpin for DraftLifecycle<'a>
impl<'a> UnsafeUnpin for DraftLifecycle<'a>
impl<'a> UnwindSafe for DraftLifecycle<'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