chore (backend-rs): use proper error type

This commit is contained in:
naskya 2024-06-10 18:09:08 +09:00
parent bc7fdc5c0b
commit b752695057
No known key found for this signature in database
GPG key ID: 712D413B3A9FED5C

View file

@ -7,10 +7,13 @@ pub struct Acct {
pub host: Option<String>,
}
impl FromStr for Acct {
type Err = ();
#[derive(thiserror::Error, Debug)]
#[error("failed to convert string '{0}' into acct")]
pub struct InvalidAcctString(String);
impl FromStr for Acct {
type Err = InvalidAcctString;
/// This never throw errors. Feel free to `.unwrap()` the result.
fn from_str(value: &str) -> Result<Self, Self::Err> {
let split: Vec<&str> = if let Some(stripped) = value.strip_prefix('@') {
stripped