pub trait Validate: Serialize + Sized {
// Provided method
fn validate<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait { ... }
}
Expand description
Validate any serializable object with json-schema
Provided Methods§
Sourcefn validate<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn validate<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
Validates this object.
If the object fails validation, this will return an Error::Validation which contains a vector of all of the validation errors.
If you’re doing multiple validations, use Validator::validate, which will re-use cached schemas.
§Examples
use stac::Item;
use stac_validate::Validate;
#[tokio::main]
async fn main() {
let mut item = Item::new("an-id");
item.validate().await.unwrap();
}
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.