pub fn parse_datamodel_or_pretty_error(datamodel_string: &str, file_name: &str) -> Result<ValidatedDatamodel, String> {
    match parse_datamodel_internal(datamodel_string, false) {
        Ok(dml) => Ok(dml),
        Err(errs) => {
            let mut buffer = std::io::Cursor::new(Vec::<u8>::new());

            for error in errs.to_error_iter() {
                writeln!(&mut buffer).expect("Failed to render error.");
                error
                    .pretty_print(&mut buffer, file_name, datamodel_string)
                    .expect("Failed to render error.");
            }

            Err(String::from_utf8(buffer.into_inner()).expect("Failed to convert error buffer."))
        }
    }
}
/// Parses and validates a datamodel string, using core attributes only.
/// In case of an error, a pretty, colorful string is returned.
Parses and validates a datamodel string, using core attributes only.
In case of an error, a pretty, colorful string is returned.
Parses and validates a datamodel string using core attributes only . In case of an error a pretty colorful string is returned .
pub fn parse_datamodel_or_pretty_error(datamodel_string: &str, file_name: &str) -> Result<ValidatedDatamodel, String> {
    match parse_datamodel_internal(datamodel_string, false) {
        Ok(dml) => Ok(dml),
        Err(errs) => {
            let mut buffer = std::io::Cursor::new(Vec::<u8>::new());
            for error in errs.to_error_iter() {
                writeln!(&mut buffer).expect("Failed to render error.");
                error
                    .pretty_print(&mut buffer, file_name, datamodel_string)
                    .expect("Failed to render error.");
            }
            Err(String::from_utf8(buffer.into_inner()).expect("Failed to convert error buffer."))
        }
    }
}
pub fn parse_datamodel_or_pretty_error ( datamodel_string : & str , file_name : & str ) -> Result < ValidatedDatamodel , String > { match parse_datamodel_internal ( datamodel_string , false ) { Ok ( dml ) => Ok ( dml ) , Err ( errs ) => { let mut buffer = std :: io :: Cursor :: new ( Vec :: < u8 > :: new ( ) ) ; for error in errs . to_error_iter ( ) { writeln ! ( mut buffer ) . expect ( " " ) ; error . pretty_print ( & mut buffer , file_name , datamodel_string ) . expect ( " " ) ; } Err ( String :: from_utf8 ( buffer . into_inner ( ) ) . expect ( " " ) ) } } }
Parses and validates a datamodel string, using core attributes only.
Parses and validates a datamodel string using core attributes only .
datamodel_string
&str
file_name
&str
datamodel_string
&str
file_name
&str