Struct cjval::CJValidator
source · pub struct CJValidator { /* private fields */ }
Expand description
A validator for CityJSON and CityJSONFeature
Implementations§
source§impl CJValidator
impl CJValidator
sourcepub fn from_str(str_dataset: &str) -> Self
pub fn from_str(str_dataset: &str) -> Self
Creates a CJValidator from a &str. Will not return an error here if the &str is not a JSON, only when validate() is called can you see that error.
use cjval::CJValidator;
let s1 = std::fs::read_to_string("./data/cube.city.json")
.expect("Couldn't read CityJSON file");
let v = CJValidator::from_str(&s1);
pub fn from_str_cjfeature(&mut self, str_cjf: &str) -> Result<(), String>
sourcepub fn add_one_extension_from_str(&mut self, ext_schema_str: &str) -> Result<()>
pub fn add_one_extension_from_str(&mut self, ext_schema_str: &str) -> Result<()>
Add the content (&str) of an Extension. The library cannot download automatically the Extensions.
use cjval::CJValidator;
let sdata = std::fs::read_to_string("./data/cube.city.json")
.expect("Couldn't read CityJSON file");
let sext = std::fs::read_to_string("./data/generic.ext.json")
.expect("Couldn't read JSON file");
let mut val = CJValidator::from_str(&sdata);
let re = val.add_one_extension_from_str(&sext);
sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Returns true if the CityJSON/Feature does not contain errors. False otherwise.
sourcepub fn validate(&self) -> IndexMap<String, ValSummary>
pub fn validate(&self) -> IndexMap<String, ValSummary>
The function to performs all the checks (errors+warnings). Return a IndexMap (a HashMap where keys are ordered) containing the check name and a ValSummary.
use cjval::CJValidator;
let s1 = std::fs::read_to_string("./data/many.json")
.expect("Couldn't read CityJSON file");
let v = CJValidator::from_str(&s1);
let re = v.validate();
for (criterion, sum) in re.iter() {
println!("=== {} ===", criterion);
println!("{}", sum);
}
pub fn get_extensions_urls(&self) -> Option<Vec<String>>
pub fn is_cityjson(&self) -> bool
pub fn is_empty_cityjson(&self) -> bool
pub fn is_cityjsonfeature(&self) -> bool
pub fn get_input_cityjson_version(&self) -> i32
pub fn get_cjseq_feature_id(&self) -> String
pub fn get_cityjson_schema_version(&self) -> String
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CJValidator
impl RefUnwindSafe for CJValidator
impl Send for CJValidator
impl Sync for CJValidator
impl Unpin for CJValidator
impl UnwindSafe for CJValidator
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