1use crate::{
4 platform::{IconApi, Wrapper},
5 platform_impl::IconImpl,
6 ContextOwner,
7 Error,
8};
9
10#[derive(Debug)]
12pub enum IconType {
13 Gif,
15 Jpeg,
17 Png,
19 Tiff,
21}
22
23#[derive(Debug)]
25pub struct Icon(IconImpl);
26
27impl Icon {
28 pub fn from_data(
35 ctx: &impl ContextOwner,
36 icon_data: &Vec<u8>,
37 icon_type: IconType,
38 ) -> Result<Self, Error> {
39 Ok(Self(IconImpl::from_data(ctx, icon_data, icon_type)?))
40 }
41
42 pub fn from_str<S>(ctx: &impl ContextOwner, title: S) -> Result<Self, Error>
48 where
49 S: Into<String>,
50 {
51 Ok(Self(IconImpl::from_str(ctx, &title.into())?))
52 }
53}
54
55impl Wrapper<IconImpl> for Icon {
56 #[inline]
57 fn get_impl(&self) -> &IconImpl { &self.0 }
58
59 #[inline]
60 fn get_impl_mut(&mut self) -> &mut IconImpl { &mut self.0 }
61}