Skip to main content

sl_types/
radar.rs

1//! Types related to SL nearby avatar radar and enter/leave messages
2
3#[cfg(feature = "chumsky")]
4use chumsky::{Parser, prelude::just};
5
6/// represents a Second Life area of significance
7#[derive(
8    Debug,
9    Clone,
10    Copy,
11    PartialEq,
12    Eq,
13    PartialOrd,
14    Ord,
15    strum::EnumIs,
16    serde::Serialize,
17    serde::Deserialize,
18)]
19pub enum Area {
20    /// chat range
21    ChatRange,
22    /// draw distance
23    DrawDistance,
24    /// region
25    Region,
26}
27
28/// parse a SecondLifeArea
29///
30/// # Errors
31///
32/// returns and error if the string could not be parsed
33#[cfg(feature = "chumsky")]
34#[must_use]
35pub fn area_parser<'src>()
36-> impl Parser<'src, &'src str, Area, chumsky::extra::Err<chumsky::error::Rich<'src, char>>> {
37    just("chat range")
38        .to(Area::ChatRange)
39        .or(just("draw distance").to(Area::DrawDistance))
40        .or(just("region").to(Area::Region))
41        .or(just("the region").to(Area::Region))
42}