spatial_led 0.3.0

Sled is an ergonomic rust library that maps out the shape of your LED strips in 2D space to help you create stunning lighting effects.
Documentation
use core::{error::Error, fmt};

use alloc::string::String;
use alloc::string::ToString as _;

#[derive(Debug, Clone, PartialEq, Eq, Hash, Default)]
/// Simple error type used by fallible Sled operations.
pub struct SledError {
    pub message: String,
}

impl SledError {
    pub fn new(message: String) -> Self {
        SledError { message }
    }

    pub fn from_error(e: impl Error) -> Self {
        SledError {
            message: e.to_string(),
        }
    }

    pub fn as_err<T>(self) -> Result<T, Self> {
        Err(self)
    }
}

impl core::convert::From<&str> for SledError {
    fn from(value: &str) -> Self {
        SledError::new(value.to_string())
    }
}

impl fmt::Display for SledError {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "{}", self.message)
    }
}

impl Error for SledError {}