use crate::{GPL3_SDPX_IDENTIFIER, PRAGMA_GROTH16_VERIFIER}; use askama::Template; pub mod encoding; #[derive(Template)] #[template(path = "header_template.askama.sol", ext = "sol")] pub(crate) struct HeaderInclusion { /// SPDX-License-Identifier pub sdpx: String, /// The `pragma` statement. pub pragma_version: String, /// The template to render alongside the header. pub template: T, } impl HeaderInclusion { pub fn builder() -> HeaderInclusionBuilder { HeaderInclusionBuilder::default() } } #[derive(Debug)] pub struct HeaderInclusionBuilder { /// SPDX-License-Identifier sdpx: String, /// The `pragma` statement. pragma_version: String, /// The template to render alongside the header. template: T, } impl Default for HeaderInclusionBuilder { fn default() -> Self { Self { sdpx: GPL3_SDPX_IDENTIFIER.to_string(), pragma_version: PRAGMA_GROTH16_VERIFIER.to_string(), template: T::default(), } } } impl HeaderInclusionBuilder { pub fn sdpx>(mut self, sdpx: S) -> Self { self.sdpx = sdpx.into(); self } pub fn pragma_version>(mut self, pragma_version: S) -> Self { self.pragma_version = pragma_version.into(); self } pub fn template(mut self, template: impl Into) -> Self { self.template = template.into(); self } pub fn build(self) -> HeaderInclusion { HeaderInclusion { sdpx: self.sdpx, pragma_version: self.pragma_version, template: self.template, } } }