pub struct Response {
pub ok: bool,
pub result: Option<Box<RawValue>>,
pub error: Option<String>,
pub stale: bool,
}Expand description
A response from the daemon to a client.
result is a pre-serialized JSON fragment (serde_json::value::RawValue)
rather than a serde_json::Value tree: the daemon serializes each result
exactly once (typed struct -> JSON text) and the framing serializer embeds
it verbatim, instead of building and then re-walking an intermediate
Value tree for every response. Clients that want typed access parse the
fragment directly into their target type; clients that just forward the
payload (the MCP server) pass the text through untouched.
Fields§
§ok: bool§result: Option<Box<RawValue>>§error: Option<String>§stale: boolSet when a Freshness::Flag query found the index behind the working
tree: the result is still returned but may not reflect recent edits.
Omitted from the wire when false so existing responses are unchanged.
Implementations§
Source§impl Response
impl Response
Sourcepub fn json<T: Serialize>(value: &T) -> Self
pub fn json<T: Serialize>(value: &T) -> Self
Build a success response by serializing value once.
pub fn err(message: impl Into<String>) -> Self
Sourcepub fn with_stale(self, stale: bool) -> Self
pub fn with_stale(self, stale: bool) -> Self
Mark this response stale (or not) and return it, for the Freshness::Flag
path to annotate an otherwise-normal answer.
Sourcepub fn result_text(&self) -> &str
pub fn result_text(&self) -> &str
The raw JSON text of the result ("null" when absent).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Response
impl<'de> Deserialize<'de> for Response
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Response
impl RefUnwindSafe for Response
impl Send for Response
impl Sync for Response
impl Unpin for Response
impl UnsafeUnpin for Response
impl UnwindSafe for Response
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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