style: formatting

This commit is contained in:
Matouš Volf 2024-08-22 22:43:34 +02:00
parent 3ca687e6d8
commit 5ee8f0484f
2 changed files with 10 additions and 10 deletions

View File

@ -12,8 +12,8 @@ pub enum ProjectCreateError {
} }
impl From<ValidationErrors> for ErrorVec<ProjectCreateError> { impl From<ValidationErrors> for ErrorVec<ProjectCreateError> {
fn from(e: ValidationErrors) -> Self { fn from(validation_errors: ValidationErrors) -> Self {
e.errors() validation_errors.errors()
.iter() .iter()
.flat_map(|(&field, error_kind)| match field { .flat_map(|(&field, error_kind)| match field {
"title" => match error_kind { "title" => match error_kind {
@ -34,18 +34,18 @@ impl From<ValidationErrors> for ErrorVec<ProjectCreateError> {
} }
} }
// has to be implemented for Dioxus server functions // Has to be implemented for Dioxus server functions.
impl Display for ProjectCreateError { impl Display for ProjectCreateError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self) write!(f, "{:?}", self)
} }
} }
// has to be implemented for Dioxus server functions // Has to be implemented for Dioxus server functions.
impl FromStr for ProjectCreateError { impl FromStr for ProjectCreateError {
type Err = (); type Err = ();
fn from_str(_: &str) -> Result<Self, Self::Err> { fn from_str(_: &str) -> Result<Self, Self::Err> {
Ok(ProjectCreateError::TitleLengthInvalid) Ok(ProjectCreateError::Error(Error::ServerInternal))
} }
} }

View File

@ -13,8 +13,8 @@ pub enum TaskCreateError {
} }
impl From<ValidationErrors> for ErrorVec<TaskCreateError> { impl From<ValidationErrors> for ErrorVec<TaskCreateError> {
fn from(e: ValidationErrors) -> Self { fn from(validation_errors: ValidationErrors) -> Self {
e.errors() validation_errors.errors()
.iter() .iter()
.flat_map(|(&field, error_kind)| match field { .flat_map(|(&field, error_kind)| match field {
"title" => match error_kind { "title" => match error_kind {
@ -35,18 +35,18 @@ impl From<ValidationErrors> for ErrorVec<TaskCreateError> {
} }
} }
// has to be implemented for Dioxus server functions // Has to be implemented for Dioxus server functions.
impl Display for TaskCreateError { impl Display for TaskCreateError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self) write!(f, "{:?}", self)
} }
} }
// has to be implemented for Dioxus server functions // Has to be implemented for Dioxus server functions.
impl FromStr for TaskCreateError { impl FromStr for TaskCreateError {
type Err = (); type Err = ();
fn from_str(_: &str) -> Result<Self, Self::Err> { fn from_str(_: &str) -> Result<Self, Self::Err> {
Ok(TaskCreateError::TitleLengthInvalid) Ok(TaskCreateError::Error(Error::ServerInternal))
} }
} }