pub trait CanonicalJsonObjectExt {
// Required methods
fn get_as_object(
&self,
field: &str,
path: impl Into<String>,
) -> Result<Option<&CanonicalJsonObject>, CanonicalJsonFieldError>;
fn get_as_object_mut(
&mut self,
field: &str,
path: impl Into<String>,
) -> Result<Option<&mut CanonicalJsonObject>, CanonicalJsonFieldError>;
fn get_as_object_or_insert_default(
&mut self,
field: impl Into<String>,
path: impl Into<String>,
) -> Result<&mut CanonicalJsonObject, CanonicalJsonFieldError>;
fn get_as_string(
&self,
field: &str,
path: impl Into<String>,
) -> Result<Option<&str>, CanonicalJsonFieldError>;
// Provided methods
fn get_as_required_object(
&self,
field: &str,
path: impl Into<String>,
) -> Result<&CanonicalJsonObject, CanonicalJsonFieldError> { ... }
fn get_as_required_object_mut(
&mut self,
field: &str,
path: impl Into<String>,
) -> Result<&mut CanonicalJsonObject, CanonicalJsonFieldError> { ... }
fn get_as_required_string(
&self,
field: &str,
path: impl Into<String>,
) -> Result<&str, CanonicalJsonFieldError> { ... }
}Expand description
Helper trait to interact with a CanonicalJsonObject.
Required Methods§
Sourcefn get_as_object(
&self,
field: &str,
path: impl Into<String>,
) -> Result<Option<&CanonicalJsonObject>, CanonicalJsonFieldError>
fn get_as_object( &self, field: &str, path: impl Into<String>, ) -> Result<Option<&CanonicalJsonObject>, CanonicalJsonFieldError>
Sourcefn get_as_object_mut(
&mut self,
field: &str,
path: impl Into<String>,
) -> Result<Option<&mut CanonicalJsonObject>, CanonicalJsonFieldError>
fn get_as_object_mut( &mut self, field: &str, path: impl Into<String>, ) -> Result<Option<&mut CanonicalJsonObject>, CanonicalJsonFieldError>
Get the given field as a mutable object.
§Parameters
field: The name of the field to access.path: The full path of the field that will be used in errors. This can be different than thefield, to clarify if this is a field nested under several objects.
§Errors
Returns an error if the field is invalid.
Sourcefn get_as_object_or_insert_default(
&mut self,
field: impl Into<String>,
path: impl Into<String>,
) -> Result<&mut CanonicalJsonObject, CanonicalJsonFieldError>
fn get_as_object_or_insert_default( &mut self, field: impl Into<String>, path: impl Into<String>, ) -> Result<&mut CanonicalJsonObject, CanonicalJsonFieldError>
Get the given required field as a mutable object or insert it if it is missing.
§Parameters
field: The name of the field to access.path: The full path of the field that will be used in errors. This can be different than thefield, to clarify if this is a field nested under several objects.
§Errors
Returns an error if the field is already be present but invalid.
Sourcefn get_as_string(
&self,
field: &str,
path: impl Into<String>,
) -> Result<Option<&str>, CanonicalJsonFieldError>
fn get_as_string( &self, field: &str, path: impl Into<String>, ) -> Result<Option<&str>, CanonicalJsonFieldError>
Provided Methods§
Sourcefn get_as_required_object(
&self,
field: &str,
path: impl Into<String>,
) -> Result<&CanonicalJsonObject, CanonicalJsonFieldError>
fn get_as_required_object( &self, field: &str, path: impl Into<String>, ) -> Result<&CanonicalJsonObject, CanonicalJsonFieldError>
Get the given required field as an object.
§Parameters
field: The name of the field to access.path: The full path of the field that will be used in errors. This can be different than thefield, to clarify if this is a field nested under several objects.
§Errors
Returns an error if the field is missing or invalid.
Sourcefn get_as_required_object_mut(
&mut self,
field: &str,
path: impl Into<String>,
) -> Result<&mut CanonicalJsonObject, CanonicalJsonFieldError>
fn get_as_required_object_mut( &mut self, field: &str, path: impl Into<String>, ) -> Result<&mut CanonicalJsonObject, CanonicalJsonFieldError>
Get the given required field as a mutable object.
§Parameters
field: The name of the field to access.path: The full path of the field that will be used in errors. This can be different than thefield, to clarify if this is a field nested under several objects.
§Errors
Returns an error if the field is missing or invalid.
Sourcefn get_as_required_string(
&self,
field: &str,
path: impl Into<String>,
) -> Result<&str, CanonicalJsonFieldError>
fn get_as_required_string( &self, field: &str, path: impl Into<String>, ) -> Result<&str, CanonicalJsonFieldError>
Get the given required field as a string.
§Parameters
field: The name of the field to access.path: The full path of the field that will be used in errors. This can be different than thefield, to clarify if this is a field nested under several objects.
§Errors
Returns an error if the field is missing or invalid.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".