1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-11-23 22:09:22 +00:00
comunicapiv3/src/api_data/movie_api.rs

38 lines
836 B
Rust
Raw Normal View History

2020-07-03 14:41:14 +00:00
//! # 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()
}
2020-07-03 14:41:14 +00:00
}