769a5a68e2
Phase 5: Replace all Box<dyn Error> return types with anyhow::Result<T>
throughout the codebase. Replace string-based Err("msg".into()) and
format!().into() patterns with bail!() and anyhow!() macros. Fix
dirs::home_dir().unwrap() in settings.rs to use a fallback path instead
of panicking when HOME is unset. Remove stray use std::error::Error
imports no longer needed.
Phase 6: Add From<&User> for CacheUser in models/user.rs and
From<&Laboratory>/From<&Laboratories> for CacheLaboratory/CacheLabsWrapper
in models/laboratory.rs. Simplify commands/login.rs to use .into()
conversions, removing the redundant to_cache_user() and to_cache_labs()
helper functions.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
22 lines
566 B
Rust
22 lines
566 B
Rust
use serde::{Deserialize, Serialize};
|
|
|
|
/// Minimal user model matching the Python cache format.
|
|
#[derive(Debug, Serialize, Deserialize, Default, Clone)]
|
|
pub struct User {
|
|
pub id: u32,
|
|
pub username: String,
|
|
pub laboratory_ids: Vec<u32>,
|
|
pub is_reviewer: bool,
|
|
}
|
|
|
|
impl From<&User> for crate::cache::CacheUser {
|
|
fn from(u: &User) -> Self {
|
|
crate::cache::CacheUser {
|
|
id: u.id,
|
|
username: u.username.clone(),
|
|
laboratory_ids: u.laboratory_ids.clone(),
|
|
is_reviewer: u.is_reviewer,
|
|
}
|
|
}
|
|
}
|