gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1111HTML 1039Markdown 12TOML 94524 Sutichaykuna

⎇ 3b12bc3a7ff895c424d3b6e7e815e8de8ac8e59a src/lib.rs Rust · 49 siq'ikuna · 1.1 KB Ñawpa willay Pi imata llamkarqan ch'uya

Add support for optional serialization/deserialization of Style with serde 3b12bc3a7 · Marcin Jaworski ·

1#![cfg_attr(not(feature = "std"), no_std)]
2#![cfg_attr(not(feature = "std"), feature(alloc))]
3#[cfg(not(feature = "std"))]
4extern crate alloc;
5
6#[macro_use]
7extern crate lazy_static;
8
9#[cfg_attr(feature = "serde", macro_use)]
10#[cfg(feature = "serde")]
11extern crate serde;
12
13pub mod geometry;
14pub mod node;
15pub mod number;
16pub mod result;
17pub mod style;
18
19mod algo;
20mod forest;
21mod id;
22
23pub use crate::node::Stretch;
24
25use core::any::Any;
26
27#[derive(Debug)]
28pub enum Error {
29    InvalidNode(node::Node),
30    Measure(Box<Any>),
31}
32
33impl std::fmt::Display for Error {
34    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
35        match *self {
36            Error::InvalidNode(ref node) => write!(f, "Invalid node {:?}", node),
37            Error::Measure(_) => write!(f, "Error during measurement"),
38        }
39    }
40}
41
42impl std::error::Error for Error {
43    fn description(&self) -> &str {
44        match *self {
45            Error::InvalidNode(_) => "The node is not part of the stretch instance",
46            Error::Measure(_) => "Error occurred inside a measurement function",
47        }
48    }
49}