id: implement rocket FromParam
This commit is contained in:
parent
e04de752ef
commit
7ab34825ad
5 changed files with 28 additions and 2 deletions
|
|
@ -7,3 +7,4 @@ edition = "2021"
|
|||
thiserror = { workspace = true }
|
||||
nanoid = "0.4.0"
|
||||
nanoid-dictionary = "0.4.3"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
|
|
@ -1,12 +1,13 @@
|
|||
use super::Error;
|
||||
use nanoid::nanoid;
|
||||
use nanoid_dictionary::NOLOOKALIKES;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt::{Display, Formatter};
|
||||
use std::str::FromStr;
|
||||
|
||||
const LENGTH: usize = 15;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
|
||||
pub struct UserID(pub String);
|
||||
|
||||
impl Display for UserID {
|
||||
|
|
@ -21,6 +22,12 @@ impl Default for UserID {
|
|||
}
|
||||
}
|
||||
|
||||
impl AsRef<str> for UserID {
|
||||
fn as_ref(&self) -> &str {
|
||||
self.0.as_ref()
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for UserID {
|
||||
type Err = Error;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue