pub enum SerializerError {
Validation(ValidatorError),
Serde {
message: String,
},
Other {
message: String,
},
}Expand description
Errors that can occur during serialization
Variants§
Validation(ValidatorError)
Validation error
Serde
Serde serialization/deserialization error
Other
Other error
Implementations§
Source§impl SerializerError
impl SerializerError
Sourcepub fn new(message: String) -> SerializerError
pub fn new(message: String) -> SerializerError
Create a new generic serializer error
Sourcepub fn validation(error: ValidatorError) -> SerializerError
pub fn validation(error: ValidatorError) -> SerializerError
Create a validation error from a ValidatorError
Sourcepub fn unique_violation(
field_name: String,
value: String,
message: String,
) -> SerializerError
pub fn unique_violation( field_name: String, value: String, message: String, ) -> SerializerError
Create a unique violation error
Sourcepub fn unique_together_violation(
field_names: Vec<String>,
values: HashMap<String, String>,
message: String,
) -> SerializerError
pub fn unique_together_violation( field_names: Vec<String>, values: HashMap<String, String>, message: String, ) -> SerializerError
Create a unique together violation error
Sourcepub fn required_field(field_name: String, message: String) -> SerializerError
pub fn required_field(field_name: String, message: String) -> SerializerError
Create a required field error
Sourcepub fn field_validation(
field_name: String,
value: String,
constraint: String,
message: String,
) -> SerializerError
pub fn field_validation( field_name: String, value: String, constraint: String, message: String, ) -> SerializerError
Create a field validation error
Sourcepub fn database_error(
message: String,
source: Option<String>,
) -> SerializerError
pub fn database_error( message: String, source: Option<String>, ) -> SerializerError
Create a database error
Sourcepub fn is_validation_error(&self) -> bool
pub fn is_validation_error(&self) -> bool
Check if this is a validation error
Sourcepub fn as_validator_error(&self) -> Option<&ValidatorError>
pub fn as_validator_error(&self) -> Option<&ValidatorError>
Try to convert to ValidatorError if this is a validation error
Trait Implementations§
Source§impl Clone for SerializerError
impl Clone for SerializerError
Source§fn clone(&self) -> SerializerError
fn clone(&self) -> SerializerError
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SerializerError
impl Debug for SerializerError
Source§impl Display for SerializerError
impl Display for SerializerError
Source§impl Error for SerializerError
impl Error for SerializerError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Source§impl From<DatabaseValidatorError> for SerializerError
impl From<DatabaseValidatorError> for SerializerError
Source§fn from(err: DatabaseValidatorError) -> Self
fn from(err: DatabaseValidatorError) -> Self
Converts to this type from the input type.
Source§impl From<ValidatorError> for SerializerError
impl From<ValidatorError> for SerializerError
Source§fn from(err: ValidatorError) -> SerializerError
fn from(err: ValidatorError) -> SerializerError
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for SerializerError
impl RefUnwindSafe for SerializerError
impl Send for SerializerError
impl Sync for SerializerError
impl Unpin for SerializerError
impl UnsafeUnpin for SerializerError
impl UnwindSafe for SerializerError
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ValidateIp for Twhere
T: ToString,
impl<T> ValidateIp for Twhere
T: ToString,
Source§fn validate_ipv4(&self) -> bool
fn validate_ipv4(&self) -> bool
Validates whether the given string is an IP V4
Source§fn validate_ipv6(&self) -> bool
fn validate_ipv6(&self) -> bool
Validates whether the given string is an IP V6
Source§fn validate_ip(&self) -> bool
fn validate_ip(&self) -> bool
Validates whether the given string is an IP