pub use vecdeque_stableix::StableIndexVecDeque;
pub use fs2::FileExt;
+pub use lazy_static::lazy_static;
+pub use regex::Regex;
pub use crate::global::*;
pub use crate::gamestate::*;
type Error = SE;
#[throws(SE)]
fn try_from(spec: &ColourSpec) -> Colour {
- // xxx check syntax
+ lazy_static! {
+ static ref RE: Regex = Regex::new(concat!(
+ r"^(?:", r"[[:alpha:]]{1,50}",
+ r"|", r"#[[:xdigit:]]{3}{1,2}",
+ r"|", r"(?:rgba?|hsla?)\([-.%\t 0-9]{1,50}\)",
+ r")$"
+ )).unwrap();
+ }
+ let s = &spec.0;
+ if !RE.is_match(s) {
+ throw!(SVGProcessingError::UnsupportedColourSpec);
+ }
spec.0.clone()
}
}