Skip to main content

octicons_pack/
lib.rs

1#![doc = include_str!("../README.md")]
2mod icons;
3pub use icons::*;
4
5mod finder;
6pub use finder::get_icon;
7
8#[cfg(feature = "pyo3")]
9use pyo3::prelude::*;
10#[cfg(feature = "pyo3")]
11pub mod py_binding;
12
13/// A Generic structure to describe a single icon.
14#[cfg_attr(feature = "pyo3", pyclass(module = "octicons_pack", get_all, frozen))]
15#[derive(Debug)]
16pub struct Icon {
17    /// The SVG data.
18    pub svg: &'static str,
19
20    /// The slug to identify the icon.
21    pub slug: &'static str,
22    // The list of `keywords` and `heights` would need (in a const context) either
23    // - a lifetime boundary
24    // - "lazy" static allocation
25    // Both solutions do not work well for python bindings.
26}
27
28#[cfg(feature = "pyo3")]
29#[cfg_attr(feature = "pyo3", pymethods)]
30impl Icon {
31    pub fn __repr__(&self) -> PyResult<String> {
32        Ok(format!("< Icon object for slug {} >", self.slug))
33    }
34}