Skip to main content

ContextualUserFragment

Trait ContextualUserFragment 

Source
pub trait ContextualUserFragment {
    // Required methods
    fn role(&self) -> &'static str;
    fn markers(&self) -> (&'static str, &'static str);
    fn body(&self) -> String;
    fn type_markers() -> (&'static str, &'static str)
       where Self: Sized;

    // Provided methods
    fn matches_text(text: &str) -> bool
       where Self: Sized { ... }
    fn render(&self) -> String { ... }
    fn into(self) -> ResponseItem
       where Self: Sized { ... }
    fn into_boxed_response_item(self: Box<Self>) -> ResponseItem { ... }
    fn into_response_input_item(self) -> ResponseInputItem
       where Self: Sized { ... }
}
Expand description

Context payload that is injected as a message fragment.

Implementations own the response role and provide the exact fragment body. Marked fragments also provide start/end markers used to recognize injected context later. render() concatenates markers and body without adding separators, so implementations should include any whitespace they need between tags in body(). Unmarked fragments should leave both markers empty, in which case the default helpers render only the body and never match arbitrary text.

Required Methods§

Source

fn role(&self) -> &'static str

Source

fn markers(&self) -> (&'static str, &'static str)

Source

fn body(&self) -> String

Source

fn type_markers() -> (&'static str, &'static str)
where Self: Sized,

Provided Methods§

Source

fn matches_text(text: &str) -> bool
where Self: Sized,

Source

fn render(&self) -> String

Source

fn into(self) -> ResponseItem
where Self: Sized,

Source

fn into_boxed_response_item(self: Box<Self>) -> ResponseItem

Source

fn into_response_input_item(self) -> ResponseInputItem
where Self: Sized,

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§