#[cfg(feature = "fmt_json")]
use serde::{Deserialize, Serialize};
use std::ops::Deref;
#[derive(Clone, Debug)]
#[cfg_attr(feature = "fmt_json", derive(Serialize, Deserialize))]
pub struct Caption(String);
pub trait HasCaption {
fn has_caption(&self) -> bool {
self.caption().is_some()
}
fn caption(&self) -> &Option<Caption>;
fn set_caption(&mut self, caption: Caption) -> &mut Self;
fn unset_caption(&mut self) -> &mut Self;
}
impl Default for Caption {
fn default() -> Self {
Self(String::new())
}
}
impl From<String> for Caption {
fn from(inner: String) -> Self {
Self::from(inner.as_str())
}
}
impl From<&str> for Caption {
fn from(inner: &str) -> Self {
Self(inner.to_string())
}
}
impl Deref for Caption {
type Target = str;
fn deref(&self) -> &Self::Target {
&self.0
}
}
inner_impl!(Caption, String);