pub struct JsonUiView {
pub schema: String,
pub layout: Option<String>,
pub title: Option<String>,
pub data: Value,
pub errors: Option<HashMap<String, Vec<String>>>,
pub components: Vec<ComponentNode>,
}Expand description
Top-level JSON-UI view container.
Every JSON-UI response is a JsonUiView containing a component tree.
The $schema field identifies the schema version for compatibility.
§Example
use ferro_json_ui::JsonUiView;
let view = JsonUiView::new()
.title("Dashboard")
.layout("app");
let json = view.to_json().unwrap();
assert!(json.contains("ferro-json-ui/v1"));Fields§
§schema: String§layout: Option<String>§title: Option<String>§data: Value§errors: Option<HashMap<String, Vec<String>>>§components: Vec<ComponentNode>Implementations§
Source§impl JsonUiView
impl JsonUiView
Sourcepub fn errors(self, errors: HashMap<String, Vec<String>>) -> Self
pub fn errors(self, errors: HashMap<String, Vec<String>>) -> Self
Set the validation errors map.
Sourcepub fn component(self, node: ComponentNode) -> Self
pub fn component(self, node: ComponentNode) -> Self
Add a single component to the view.
Sourcepub fn components(self, nodes: Vec<ComponentNode>) -> Self
pub fn components(self, nodes: Vec<ComponentNode>) -> Self
Set all components at once, replacing any existing.
Sourcepub fn to_json_pretty(&self) -> Result<String, Error>
pub fn to_json_pretty(&self) -> Result<String, Error>
Serialize the view to a pretty-printed JSON string.
Trait Implementations§
Source§impl Clone for JsonUiView
impl Clone for JsonUiView
Source§fn clone(&self) -> JsonUiView
fn clone(&self) -> JsonUiView
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for JsonUiView
impl Debug for JsonUiView
Source§impl Default for JsonUiView
impl Default for JsonUiView
Source§impl<'de> Deserialize<'de> for JsonUiView
impl<'de> Deserialize<'de> for JsonUiView
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for JsonUiView
impl PartialEq for JsonUiView
Source§impl Serialize for JsonUiView
impl Serialize for JsonUiView
impl StructuralPartialEq for JsonUiView
Auto Trait Implementations§
impl Freeze for JsonUiView
impl RefUnwindSafe for JsonUiView
impl Send for JsonUiView
impl Sync for JsonUiView
impl Unpin for JsonUiView
impl UnsafeUnpin for JsonUiView
impl UnwindSafe for JsonUiView
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