1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
//! # ytsaurus-yson
//!
//! A Rust library for serializing and deserializing the YSON format.
// Internal modules hidden from the public API to reduce clutter
pub
/// Tools for working with YSON attributes and metadata.
/// Deserialization logic and types.
/// Error types and handling.
pub
/// Abstract Syntax Tree (AST) representation of YSON values.
/// Locating record boundaries in a partially-read buffer.
/// Serialization logic and types.
pub
// Public re-exports
pub use crateWithAttributes;
pub use crateStreamDeserializer;
pub use crateYsonError;
pub use crate;
pub use crate;
pub use crateYsonFormat;
use crateDeserializer;
use crateSerializer;
use ;
/// Helper to determine if a format is binary.
/// Deserializes an instance of type `T` from a byte slice in the specified YSON format.
///
/// # Examples
///
/// ```
/// use ytsaurus_yson::{from_slice, YsonFormat};
/// use std::collections::HashMap;
///
/// let data = b"{key=\"42\"; status=\"active\"}";
/// let map: HashMap<String, String> = from_slice(data, YsonFormat::Text).unwrap();
///
/// assert_eq!(map.get("key").unwrap(), "42");
/// ```
///
/// # Errors
///
/// Returns [`YsonError`] if:
/// - The input data has invalid YSON syntax.
/// - The input contains invalid UTF-8 sequences (when in text mode).
/// - The data structure does not match the requirements of the target type `T`.
/// Serializes the given value into a byte vector using the specified YSON format.
///
/// # Examples
///
/// ```
/// use ytsaurus_yson::{to_vec, YsonFormat};
///
/// let data = vec![1, 2, 3];
/// let bytes = to_vec(&data, YsonFormat::Binary).unwrap();
/// assert!(!bytes.is_empty());
/// ```
///
/// # Errors
///
/// Returns [`YsonError`] if serialization fails, which can occur due to:
/// - Recursion depth limits being exceeded.
/// - Custom serialization errors defined by the type `T`.
/// Serializes the given value into a YSON-formatted string.
///
/// # Examples
///
/// ```
/// use ytsaurus_yson::{to_string, YsonFormat};
///
/// let val = ("answer", 42);
/// let res = to_string(&val, YsonFormat::Text).unwrap();
/// assert_eq!(res, "[answer;42]");
/// ```
///
/// # Errors
///
/// Returns an error if:
/// - The format is [`YsonFormat::Binary`] (binary YSON cannot be represented as a UTF-8 string).
/// - The serialization output contains invalid UTF-8 sequences.
/// - Serialization fails due to internal structural constraints.