pub enum Block {
Text {
id: String,
text: String,
},
Fields {
id: String,
items: Vec<Field>,
},
Table {
id: String,
columns: Vec<String>,
rows: Vec<Vec<Value>>,
offset: Option<u64>,
total: Option<u64>,
},
List {
id: String,
items: Vec<Value>,
ordered: Option<bool>,
offset: Option<u64>,
total: Option<u64>,
},
Custom {
id: String,
payload: Value,
},
Notice {
id: String,
severity: Severity,
text: String,
},
Media {
id: String,
mime_type: String,
url: String,
alt: Option<String>,
},
}Expand description
One semantic block. The id is assigned by the library (constructors leave
it empty; it is filled in when the block is inserted into a window).
Note: this enum deliberately uses internal tagging
#[serde(tag = "type")] — this is the wire format mandated by MCP GUI
Bridge protocol §4.4 ({"type":"text","id":...,"text":...}). It cannot use
serde’s default external tagging without violating the protocol and breaking
agent interop. This is the single documented exception to the
the repo’s docs/code-style.md “no tag="type"” rule (that rule targets
WASM binary size and does not apply to this server crate).
Variants§
Text
A paragraph of text.
Fields
A group of key/value fields.
Table
A table.
Fields
List
A list.
Fields
Custom
A fallback block carrying an arbitrary structured payload.
Notice
A status / notice block.
Fields
Media
Read-side rich media: an image / screenshot / chart.
Implementations§
Source§impl Block
impl Block
Sourcepub fn fields<I, F>(items: I) -> Block
pub fn fields<I, F>(items: I) -> Block
Build a fields block from any iterable of items convertible to
Field.
Sourcepub fn table<C, R, Row, Cell>(columns: C, rows: R) -> Blockwhere
C: IntoIterator<Item = Cell>,
Cell: Into<String>,
R: IntoIterator<Item = Row>,
Row: IntoIterator,
<Row as IntoIterator>::Item: Serialize,
pub fn table<C, R, Row, Cell>(columns: C, rows: R) -> Blockwhere
C: IntoIterator<Item = Cell>,
Cell: Into<String>,
R: IntoIterator<Item = Row>,
Row: IntoIterator,
<Row as IntoIterator>::Item: Serialize,
Build a table block. Cells accept any Serialize.
Sourcepub fn table_truncated<C, R, Row, Cell>(
columns: C,
rows: R,
offset: u64,
total: u64,
) -> Blockwhere
C: IntoIterator<Item = Cell>,
Cell: Into<String>,
R: IntoIterator<Item = Row>,
Row: IntoIterator,
<Row as IntoIterator>::Item: Serialize,
pub fn table_truncated<C, R, Row, Cell>(
columns: C,
rows: R,
offset: u64,
total: u64,
) -> Blockwhere
C: IntoIterator<Item = Cell>,
Cell: Into<String>,
R: IntoIterator<Item = Row>,
Row: IntoIterator,
<Row as IntoIterator>::Item: Serialize,
Build a truncated table block (§9): rows is the shown window,
starting at offset, out of total rows overall.
Sourcepub fn list<I, T>(items: I) -> Blockwhere
I: IntoIterator<Item = T>,
T: Serialize,
pub fn list<I, T>(items: I) -> Blockwhere
I: IntoIterator<Item = T>,
T: Serialize,
Build an unordered list block. Items accept any Serialize.
Sourcepub fn ordered_list<I, T>(items: I) -> Blockwhere
I: IntoIterator<Item = T>,
T: Serialize,
pub fn ordered_list<I, T>(items: I) -> Blockwhere
I: IntoIterator<Item = T>,
T: Serialize,
Build an ordered list block. Items accept any Serialize.
Sourcepub fn list_truncated<I, T>(
items: I,
ordered: bool,
offset: u64,
total: u64,
) -> Blockwhere
I: IntoIterator<Item = T>,
T: Serialize,
pub fn list_truncated<I, T>(
items: I,
ordered: bool,
offset: u64,
total: u64,
) -> Blockwhere
I: IntoIterator<Item = T>,
T: Serialize,
Build a truncated list block (§9): items is the shown window,
starting at offset, out of total items overall. ordered selects an
ordered (1. 2. 3.) or unordered list.
Trait Implementations§
Source§impl Serialize for Block
impl Serialize for Block
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for Block
impl RefUnwindSafe for Block
impl Send for Block
impl Sync for Block
impl Unpin for Block
impl UnsafeUnpin for Block
impl UnwindSafe for Block
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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