feat: added basic user management

This commit is contained in:
Andrew Rioux
2025-01-26 17:33:26 -05:00
parent dee6c62bf2
commit bee66a8d6c
17 changed files with 587 additions and 120 deletions
+37
View File
@@ -0,0 +1,37 @@
#[derive(Debug)]
pub enum Error {
UserCreate(String),
#[cfg(feature = "ssr")]
Sqlx(sqlx::Error),
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Error::UserCreate(err) => {
write!(f, "user create error: {err}")
}
#[cfg(feature = "ssr")]
Error::Sqlx(err) => {
write!(f, "sqlx error: {err:?}")
}
}
}
}
impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
#[cfg(feature = "ssr")]
Error::Sqlx(err) => Some(err),
_ => None,
}
}
}
#[cfg(feature = "ssr")]
impl From<sqlx::Error> for Error {
fn from(err: sqlx::Error) -> Self {
Self::Sqlx(err)
}
}