Attribute Macro butane_codegen::butane_type [−][src]
#[butane_type]
Expand description
Attribute macro which marks a type as being available to butane for use in models.
May be used on type aliases, structs, or enums. Except when used on type aliases, it must be given a parameter specifying the SqlType it can be converted to.
E.g.
ⓘ
#[butane_type] pub type CurrencyAmount = f64; #[butane_type(Text)] pub enum Currency { Dollars, Pounds, Euros, } impl ToSql for Currency { fn to_sql(&self) -> SqlVal { SqlVal::Text( match self { Self::Dollars => "dollars", Self::Pounds => "pounds", Self::Euros => "euros", } .to_string()) } }