topcoat-view 0.0.2

A modular, batteries-included Rust web framework for server-rendered apps.
Documentation
/// A props struct with a generated typestate builder.
///
/// Implemented by [`#[derive(Props)]`][derive]. The derive also generates an
/// inherent `builder()` function on the struct, so this trait only needs to be
/// in scope when the builder is constructed generically.
///
/// [derive]: derive.Props.html
pub trait Props {
    /// The builder type in its initial state, with no properties set.
    type Builder;

    /// Returns a builder with no properties set.
    fn builder() -> Self::Builder;
}

/// Typestate marker for a required property that has been set.
///
/// Builders generated by [`#[derive(Props)]`][derive] track each required
/// property in a generic argument. Calling the property's setter flips that
/// argument to [`Set`]; before that it is a generated marker type named after
/// the property.
///
/// [derive]: derive.Props.html
pub struct Set;

/// Implemented by typestate markers of properties that have been set.
///
/// `build()` on a generated builder requires every required property's marker
/// to implement this trait. Markers of unset properties are types named after
/// the property, so the compile error names exactly which property is missing.
#[diagnostic::on_unimplemented(
    message = "missing required property `{Self}`",
    label = "the property `{Self}` was not set",
    note = "every property without `#[default]` must be set before calling `build()`"
)]
pub trait IsSet {}

impl IsSet for Set {}