weakauras_codec_ace_serialize/lib.rs
1// Copyright 2020-2025 Velithris
2// SPDX-License-Identifier: MIT
3
4//! This library provides routines for deserializing and serializing [`LuaValues`](LuaValue)
5//! in a way compatible with a Lua library called AceSerialize.
6//!
7//! # Deserialization example
8//!
9//! This is how you can use the library to deserialize strings produced by AceSerialize.
10//!
11//! ```
12//! use weakauras_codec_ace_serialize::{DeserializationError, Deserializer};
13//!
14//! fn main() -> Result<(), DeserializationError> {
15//! assert_eq!(
16//! Deserializer::from_str("^1^SHello,~`world!^^")
17//! .deserialize_first()?
18//! .unwrap(),
19//! "Hello, world!".into()
20//! );
21//! Ok(())
22//! }
23//! ```
24//!
25//! # Serialization example
26//!
27//! This is how you can use the library to serialize values in a way compatible with AceSerialize.
28//!
29//! ```
30//! use weakauras_codec_ace_serialize::{SerializationError, Serializer};
31//!
32//! fn main() -> Result<(), SerializationError> {
33//! assert_eq!(
34//! Serializer::serialize_one(&"Hello, world!".into(), None)?,
35//! "^1^SHello,~`world!^^"
36//! );
37//! Ok(())
38//! }
39//! ```
40//!
41//! # Crate features
42//!
43//! * **lua-value-arbitrary** - Implement `arbitrary::Arbitrary` for [`LuaValue`]. **Disabled** by default.
44//! * **lua-value-fnv** - Use `fnv` instead of `BTreeMap` as the implementation of [`LuaValue::Map`]. **Disabled** by default.
45//! * **lua-value-indexmap** - Use `indexmap` instead of `BTreeMap` as the implementation of [`LuaValue::Map`]. **Disabled** by default.
46//! * **serde** - Allow serializing and deserializing [`LuaValue`] using `serde`. **Disabled** by default.
47
48#![deny(missing_docs)]
49
50/// Deserialization.
51pub mod deserialization;
52/// Error types.
53pub mod error;
54pub(crate) mod macros;
55/// Serialization.
56pub mod serialization;
57
58pub use deserialization::Deserializer;
59pub use error::*;
60pub use serialization::Serializer;
61pub use weakauras_codec_lua_value::LuaValue;