online-dsl-forge 0.3.0

A bounded parser and runtime for in-memory DSL expressions.
Documentation
use std::error::Error;
use std::fmt;

#[derive(Debug, Clone, Eq, PartialEq)]
pub struct RulepackRenderError {
  message: String,
}

impl RulepackRenderError {
  pub fn new(message: impl Into<String>) -> Self {
    Self {
      message: message.into(),
    }
  }
}

impl fmt::Display for RulepackRenderError {
  fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
    formatter.write_str(&self.message)
  }
}

impl Error for RulepackRenderError {}

pub(crate) type RenderResult<T> = Result<T, RulepackRenderError>;

pub(crate) fn fail<T>(message: impl Into<String>) -> RenderResult<T> {
  Err(RulepackRenderError::new(message))
}