mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-11-23 13:59:21 +00:00
38 lines
836 B
Rust
38 lines
836 B
Rust
//! # Movie API information
|
|
//!
|
|
//! @author Pierre Hubert
|
|
use serde::Serialize;
|
|
|
|
use crate::data::movie::Movie;
|
|
use crate::utils::user_data_utils::user_data_url;
|
|
|
|
#[derive(Serialize)]
|
|
#[allow(non_snake_case)]
|
|
pub struct MovieAPI {
|
|
id: u64,
|
|
uri: String,
|
|
url: String,
|
|
userID: u64,
|
|
name: String,
|
|
file_type: String,
|
|
size: usize,
|
|
}
|
|
|
|
impl MovieAPI {
|
|
/// Construct a new instance of movie
|
|
pub fn new(m: &Movie) -> MovieAPI {
|
|
MovieAPI {
|
|
id: m.id,
|
|
uri: m.uri.clone(),
|
|
url: user_data_url(m.uri.as_str()),
|
|
userID: m.user_id.id(),
|
|
name: m.name.clone(),
|
|
file_type: m.file_type.clone(),
|
|
size: m.size,
|
|
}
|
|
}
|
|
|
|
pub fn for_list(l: &Vec<Movie>) -> Vec<MovieAPI> {
|
|
l.iter().map(Self::new).collect()
|
|
}
|
|
} |