use std::borrow::Cow;
#[derive(Clone, Debug)]
pub struct Config<'a> {
pub(crate) class_name: Cow<'a, str>,
pub(crate) indent: u32,
pub(crate) access_style: AccessStyle,
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum AccessStyle {
TypedArrays,
DataView,
}
impl Default for AccessStyle {
fn default() -> Self {
AccessStyle::DataView
}
}
impl<'a> Default for Config<'a> {
fn default() -> Self {
Config {
class_name: "WasmWrapper".into(),
indent: 4,
access_style: AccessStyle::default(),
}
}
}
impl<'a> Config<'a> {
pub fn new() -> Self {
Self::default()
}
pub fn with_class_name<T: Into<Cow<'a, str>>>(&mut self, class_name: T) -> &mut Self {
self.class_name = class_name.into();
self
}
pub fn with_indent(&mut self, indent: u32) -> &mut Self {
self.indent = indent;
self
}
pub fn with_array_access_style(&mut self, style: AccessStyle) -> &mut Self {
self.access_style = style;
self
}
}