31 lines
873 B
Rust
31 lines
873 B
Rust
use std::fmt::Display;
|
|
|
|
use gamenight_api_client_rs::models;
|
|
use uuid::Uuid;
|
|
|
|
#[derive(Clone)]
|
|
pub struct Location {
|
|
pub id: Uuid,
|
|
pub name: String,
|
|
pub address: Option<String>,
|
|
pub note: Option<String>,
|
|
}
|
|
|
|
impl From<models::Location> for Location {
|
|
fn from(location: models::Location) -> Self {
|
|
Self {
|
|
id: Uuid::parse_str(&location.id).unwrap(),
|
|
name: location.name,
|
|
address: location.address,
|
|
note: location.note
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Display for Location {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
write!(f, r#"name: {}
|
|
address: {}
|
|
note: {}"#, &self.name, &<std::option::Option<std::string::String> as Clone>::clone(&self.address).unwrap_or_default(), &<std::option::Option<std::string::String> as Clone>::clone(&self.note).unwrap_or_default())
|
|
}
|
|
} |