forked from Roflin/gamenight
25 lines
638 B
Rust
25 lines
638 B
Rust
use std::fmt::{Display, Formatter};
|
|
use gamenight_api_client_rs::models::Location;
|
|
use uuid::Uuid;
|
|
use crate::flows::FlowError;
|
|
|
|
pub struct LocationSelectData {
|
|
pub id: Uuid,
|
|
pub name: String,
|
|
}
|
|
|
|
impl Display for LocationSelectData {
|
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self.name) }
|
|
}
|
|
|
|
impl TryFrom<&Location> for LocationSelectData {
|
|
type Error = FlowError;
|
|
|
|
fn try_from(value: &Location) -> Result<Self, Self::Error> {
|
|
let uuid = Uuid::parse_str(&value.id)?;
|
|
Ok(LocationSelectData {
|
|
id: uuid,
|
|
name: value.name.clone(),
|
|
})
|
|
}
|
|
} |