serde_brief/
config.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//! Configuration for (de-)serialization.

use ::core::num::NonZeroUsize;

// TODO:
// - Add max sequence/map size limit.
// - Add max-depth limit.
/// Configuration for (de-)serialization.
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
pub struct Config {
	/// Whether to use indices instead of strings as keys for struct-fields/enum-variants.
	pub use_indices: bool,
	/// Whether to return an error if there is excess data in the input.
	pub error_on_excess_data: bool,
	/// Maximum number of bytes to read or write, in any limit.
	pub max_size: Option<NonZeroUsize>,
}

impl Default for Config {
	fn default() -> Self {
		Self { use_indices: false, error_on_excess_data: true, max_size: None }
	}
}