serde_llsd/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 de;
18pub mod ser;
19
20pub use crate::{
21 de::{
22 auto_from_bytes, auto_from_str,
23 binary::from_bytes as binary_from_bytes,
24 binary::from_reader as binary_from_reader, // Name clash
25 xml::from_reader,
26 xml::from_str,
27 notation::from_bytes as notation_from_bytes,
28 notation::from_str as notation_from_str,
29 },
30 ser::{
31 binary::to_bytes,
32 binary::to_writer as binary_to_writer, // Name clash
33 xml::to_string,
34 xml::to_writer,
35 notation::to_string as notation_to_string, // Name clash
36 },
37};
38
39use enum_as_inner::EnumAsInner;
40use std::collections::HashMap;
41use uuid::Uuid;
42
43/// The primitive LLSD data item.
44/// Serialization takes a tree of these.
45/// Deserialization returns a tree of these.
46#[derive(Debug, Clone, PartialEq, EnumAsInner)]
47pub enum LLSDValue {
48 /// Not convertable.
49 Undefined,
50 /// Boolean
51 Boolean(bool),
52 /// Real, always 64-bit.
53 Real(f64),
54 /// Integer, always 32 bit, for historical reasons.
55 Integer(i32),
56 /// UUID, as a binary 128 bit value.
57 UUID(Uuid),
58 /// String, UTF-8.
59 String(String),
60 /// Date, as seconds relative to the UNIX epoch, January 1, 1970.
61 Date(i64),
62 /// Universal Resource Identifier
63 URI(String),
64 /// Array of bytes.
65 Binary(Vec<u8>),
66 /// Key/value set of more LLSDValue items.
67 Map(HashMap<String, LLSDValue>),
68 /// Array of more LLSDValue items.
69 Array(Vec<LLSDValue>),
70}