use std::collections::HashMap;
use causa_kernel::MediaRef;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct MediaPayload {
pub media_type: String,
pub data_base64: String,
}
impl MediaPayload {
pub fn new(media_type: impl Into<String>, data_base64: impl Into<String>) -> Self {
Self {
media_type: media_type.into(),
data_base64: data_base64.into(),
}
}
}
#[derive(Debug, Clone, Default)]
pub struct MediaSet {
by_reference: HashMap<String, MediaPayload>,
}
impl MediaSet {
pub fn new() -> Self {
Self::default()
}
pub fn insert(&mut self, reference: impl Into<String>, payload: MediaPayload) {
self.by_reference.insert(reference.into(), payload);
}
pub fn get(&self, r: &MediaRef) -> Option<&MediaPayload> {
self.by_reference.get(&r.reference)
}
}