serde_llsd_benthic/
lib.rs

1//! # lib.rs
2//!
3//!  Rust library for serializing and de-serializing data in
4//!  Linden Lab Structured Data format.
5//!
6//!  Serde version.
7//!
8//!  Format documentation is at http://wiki.secondlife.com/wiki/LLSD
9//
10//  Animats
11//  October, 2021.
12//  License: LGPL.
13//
14//
15//  Modules
16//
17pub mod converter;
18pub mod de;
19pub mod ser;
20
21pub use crate::{
22    de::{
23        auto_from_bytes,
24        auto_from_str,
25        binary::from_bytes as binary_from_bytes,
26        binary::from_reader as binary_from_reader, // Name clash
27        notation::from_bytes as notation_from_bytes,
28        notation::from_str as notation_from_str,
29        xml::from_str,
30    },
31    ser::{
32        binary::to_bytes,
33        binary::to_writer as binary_to_writer,     // Name clash
34        notation::to_string as notation_to_string, // Name clash
35        xml::to_string,
36        xml::to_writer,
37    },
38};
39
40use enum_as_inner::EnumAsInner;
41use std::collections::HashMap;
42use uuid::Uuid;
43
44/// The primitive LLSD data item.
45/// Serialization takes a tree of these.
46/// Deserialization returns a tree of these.
47#[derive(Debug, Clone, PartialEq, EnumAsInner)]
48pub enum LLSDValue {
49    /// Not convertable.
50    Undefined,
51    /// Boolean
52    Boolean(bool),
53    /// Real, always 64-bit.
54    Real(f64),
55    /// Integer, always 32 bit, for historical reasons.
56    Integer(i32),
57    /// UUID, as a binary 128 bit value.
58    UUID(Uuid),
59    /// String, UTF-8.
60    String(String),
61    /// Date, as seconds relative to the UNIX epoch, January 1, 1970.
62    Date(i64),
63    /// Universal Resource Identifier
64    URI(String),
65    /// Array of bytes.
66    Binary(Vec<u8>),
67    /// Key/value set of more LLSDValue items.
68    Map(HashMap<String, LLSDValue>),
69    /// Array of more LLSDValue items.
70    Array(Vec<LLSDValue>),
71}