Struct green_barrel::models::output_data::OutputDataCheck
source · [−]pub struct OutputDataCheck { /* private fields */ }
Expand description
Helper methods for converting output data (use in the paladins.rs module).
Implementations
sourceimpl OutputDataCheck
impl OutputDataCheck
sourcepub fn from(
is_valid: bool,
final_doc: Option<Document>,
final_widget_map: HashMap<String, Widget>,
service_name: String,
model_name: String,
fields_name: Vec<String>
) -> Self
pub fn from(
is_valid: bool,
final_doc: Option<Document>,
final_widget_map: HashMap<String, Widget>,
service_name: String,
model_name: String,
fields_name: Vec<String>
) -> Self
Output data initialization.
sourcepub fn hash(&self) -> String
pub fn hash(&self) -> String
Get Hash-line
Example:
let model_name = ModelName {...};
let output_data = model_name.check()?;
let output_data = model_name.save(None, None)?;
println!("{}", output_data.hash());
sourcepub fn object_id(&self) -> Result<ObjectId, Box<dyn Error>>
pub fn object_id(&self) -> Result<ObjectId, Box<dyn Error>>
Get MongoDB ID from hash-line
Example:
let model_name = ModelName {...};
let output_data = model_name.check()?;
let output_data = model_name.save(None, None)?;
println!("{:?}", output_data.object_id()?);
sourcepub fn get_doc(&self) -> Option<Document>
pub fn get_doc(&self) -> Option<Document>
Get/Set final document ( Wig - Widgets )
Example:
let model_name = ModelName {...};
let output_data = model_name.check()?;
let output_data = model_name.save(None, None)?;
println!("{:?}", output_data.get_doc());
println!("{:?}", output_data.set_doc(Some(new_doc)));
pub fn set_doc(&mut self, new_doc: Option<Document>)
sourcepub fn to_wig(&self) -> HashMap<String, Widget>
pub fn to_wig(&self) -> HashMap<String, Widget>
Get/Set Map of Widgets ( Wig - Widgets )
Example:
let model_name = ModelName {...};
let output_data = model_name.check()?;
let output_data = model_name.save(None, None)?;
println!("{:?}", output_data.to_wig());
println!("{:?}", output_data.set_wig(updated_widget_map));
pub fn set_wig(&mut self, new_widget_map: HashMap<String, Widget>)
sourcepub fn to_json(&self) -> Result<String, Box<dyn Error>>
pub fn to_json(&self) -> Result<String, Box<dyn Error>>
Get Json-line
Example:
let model_name = ModelName {...};
let output_data = model_name.check()?;
let output_data = model_name.save(None, None)?;
println!("{}", output_data.to_json()?);
sourcepub fn to_json_for_admin(&self) -> Result<String, Box<dyn Error>>
pub fn to_json_for_admin(&self) -> Result<String, Box<dyn Error>>
Json-line for admin panel. ( converts a widget map to a list, in the order of the Model fields )
Example:
let model_name = ModelName {...};
let output_data = model_name.check()?;
let output_data = model_name.save(None, None)?;
println!("{}", output_data.to_json_for_admin()?);
sourcepub fn to_html(
&self,
action: Option<&str>,
method: Option<HttpMethod>,
enctype: Option<Enctype>
) -> Result<String, Box<dyn Error>>
pub fn to_html(
&self,
action: Option<&str>,
method: Option<HttpMethod>,
enctype: Option<Enctype>
) -> Result<String, Box<dyn Error>>
Get Html-code
Example:
let model_name = ModelName {...};
let output_data = model_name.check()?;
let output_data = model_name.save(None, None)?;
//
println!("{}", output_data.to_html(None, None, None)?);
// OR
println!("{}", output_data.to_html(Some("/login"), Some(HttpMethod::POST), Some(Enctype::Multipart))?);
sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Get validation status (boolean).
Example:
let model_name = ModelName {...};
let output_data = model_name.check()?;
let output_data = model_name.save(None, None)?;
assert!(output_data.is_valid());
Trait Implementations
sourceimpl Converters for OutputDataCheck
impl Converters for OutputDataCheck
sourcefn one_to_wig(
doc: Option<Document>,
ignore_fields: &Vec<String>,
widget_type_map: &HashMap<String, String>,
model_name: &str,
fields_name: &Vec<String>,
map_widgets: HashMap<String, Widget>
) -> Result<Option<HashMap<String, Widget>>, Box<dyn Error>>
fn one_to_wig(
doc: Option<Document>,
ignore_fields: &Vec<String>,
widget_type_map: &HashMap<String, String>,
model_name: &str,
fields_name: &Vec<String>,
map_widgets: HashMap<String, Widget>
) -> Result<Option<HashMap<String, Widget>>, Box<dyn Error>>
Get widgets map from document ( presence of widgets ).
sourcefn widget_map_to_json(
widget_map: HashMap<String, Widget>
) -> Result<String, Box<dyn Error>>
fn widget_map_to_json(
widget_map: HashMap<String, Widget>
) -> Result<String, Box<dyn Error>>
Get json-line from widget map.
sourcefn to_model_instance(
doc: Option<Document>,
ignore_fields: &Vec<String>,
widget_type_map: &HashMap<String, String>,
model_name: &str
) -> Result<Option<Self>, Box<dyn Error>> where
Self: DeserializeOwned + Sized,
fn to_model_instance(
doc: Option<Document>,
ignore_fields: &Vec<String>,
widget_type_map: &HashMap<String, String>,
model_name: &str
) -> Result<Option<Self>, Box<dyn Error>> where
Self: DeserializeOwned + Sized,
Get model instance from document.
Hint: For the save
, update
, delete
operations. Read more
sourcefn to_prepared_doc(
doc: Document,
ignore_fields: &Vec<String>,
widget_type_map: &HashMap<String, String>,
model_name: &str
) -> Result<Document, Box<dyn Error>>
fn to_prepared_doc(
doc: Document,
ignore_fields: &Vec<String>,
widget_type_map: &HashMap<String, String>,
model_name: &str
) -> Result<Document, Box<dyn Error>>
Get prepared document. Hint: Converting data types to model-friendly formats. Read more
sourcefn many_to_doc(
filter: Option<Document>,
find_options: Option<FindOptions>,
collection: Collection
) -> Result<Vec<Document>, Box<dyn Error>>
fn many_to_doc(
filter: Option<Document>,
find_options: Option<FindOptions>,
collection: Collection
) -> Result<Vec<Document>, Box<dyn Error>>
Get prepared documents ( missing widgets ).
sourceimpl Debug for OutputDataCheck
impl Debug for OutputDataCheck
sourceimpl GenerateHtml for OutputDataCheck
impl GenerateHtml for OutputDataCheck
sourcefn generate_html(
url_action: Option<&str>,
http_method: Option<HttpMethod>,
enctype: Option<Enctype>,
service_name: &str,
model_name: &str,
fields_name: &Vec<String>,
widget_map: &HashMap<String, Widget>
) -> Result<String, Box<dyn Error>>
fn generate_html(
url_action: Option<&str>,
http_method: Option<HttpMethod>,
enctype: Option<Enctype>,
service_name: &str,
model_name: &str,
fields_name: &Vec<String>,
widget_map: &HashMap<String, Widget>
) -> Result<String, Box<dyn Error>>
Rendering HTML-controls code for Form. Hint: If necessary, customize the code generation yourself using html and css классы from Bootstrap, Material Design, etc. Read more
Auto Trait Implementations
impl RefUnwindSafe for OutputDataCheck
impl Send for OutputDataCheck
impl Sync for OutputDataCheck
impl Unpin for OutputDataCheck
impl UnwindSafe for OutputDataCheck
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Pointable for T
impl<T> Pointable for T
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more