id: implement rocket FromParam

This commit is contained in:
Philippe Loctaux 2023-03-08 00:15:34 +01:00
parent e04de752ef
commit 7ab34825ad
5 changed files with 28 additions and 2 deletions

View file

@ -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;