ferrum-email-core 0.1.0

Core types, traits, and node tree for the Ferrum Email framework
Documentation
  • Coverage
  • 40.7%
    70 out of 172 items documented1 out of 52 items with examples
  • Size
  • Source code size: 25.88 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 8.13 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 16s Average build duration of successful builds.
  • all releases: 15s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • AutomataControls

ferrum-email-core

The foundation crate for the Ferrum Email framework.

What's Inside

  • Component trait — the core abstraction. Every email template and reusable element implements this.
  • Node tree — the intermediate representation between components and rendered HTML. Consists of Element, Text, Fragment, and None variants.
  • Style system — type-safe CSS properties (color, font-size, padding, etc.) with a to_css() method for inline style generation.
  • Color — hex, RGB, RGBA, named, and transparent color values.
  • Spacing — padding/margin with all(), xy(), new() constructors.
  • Primitive typesPx, Percent, SizeValue, FontWeight, TextAlign, VerticalAlign, FontFamily, LineHeight, Display, BorderStyle, TextDecoration, HeadingLevel.

Usage

use ferrum_email_core::{Component, Node, Element, Tag, Style, Color, Px};

struct MyComponent;

impl Component for MyComponent {
    fn render(&self) -> Node {
        let mut style = Style::new();
        style.color = Some(Color::hex("333333"));
        style.font_size = Some(Px(16));

        Node::Element(
            Element::new(Tag::P)
                .style(style)
                .child(Node::text("Hello from Ferrum!")),
        )
    }
}

Design

The Node tree is intentionally simple — it's a direct mapping to HTML elements with typed attributes and styles. This keeps the renderer straightforward while giving components full control over their output.

All style values are type-checked at compile time. You cannot construct invalid CSS values — Px(16) renders to "16px", Color::hex("ff0000") renders to "#ff0000", etc.

License

MIT OR Apache-2.0