pub struct Array { /* private fields */ }
Expand description
Type representing a TOML array,
payload of the Value::Array
variant’s value
Implementations§
source§impl Array
impl Array
Formatting
sourcepub fn set_trailing_comma(&mut self, yes: bool)
pub fn set_trailing_comma(&mut self, yes: bool)
Set whether the array will use a trailing comma
Examples found in repository?
31 32 33 34 35 36 37 38 39 40 41 42 43 44
fn visit_array_mut(&mut self, node: &mut crate::Array) {
crate::visit_mut::visit_array_mut(self, node);
if (0..=1).contains(&node.len()) {
node.set_trailing("");
node.set_trailing_comma(false);
} else {
for item in node.iter_mut() {
item.decor_mut().set_prefix("\n ");
}
node.set_trailing("\n");
node.set_trailing_comma(true);
}
}
More examples
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374
fn decorate_array(array: &mut Array) {
for (i, value) in array
.values
.iter_mut()
.filter_map(Item::as_value_mut)
.enumerate()
{
// [value1, value2, value3]
if i == 0 {
value.decorate(DEFAULT_LEADING_VALUE_DECOR.0, DEFAULT_LEADING_VALUE_DECOR.1);
} else {
value.decorate(DEFAULT_VALUE_DECOR.0, DEFAULT_VALUE_DECOR.1);
}
}
// Since everything is now on the same line, remove trailing commas and whitespace.
array.set_trailing_comma(false);
array.set_trailing("");
}
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
pub(crate) fn array_values(input: Input<'_>) -> IResult<Input<'_>, Array, ParserError<'_>> {
(
opt(
(separated_list1(ARRAY_SEP, array_value), opt(ARRAY_SEP)).map(
|(v, trailing): (Vec<Value>, Option<u8>)| {
(
Array::with_vec(v.into_iter().map(Item::Value).collect()),
trailing.is_some(),
)
},
),
),
ws_comment_newline,
)
.map_res::<_, _, std::str::Utf8Error>(|(array, trailing)| {
let (mut array, comma) = array.unwrap_or_default();
array.set_trailing_comma(comma);
array.set_trailing(std::str::from_utf8(trailing)?);
Ok(array)
})
.parse(input)
}
sourcepub fn trailing_comma(&self) -> bool
pub fn trailing_comma(&self) -> bool
Whether the array will use a trailing comma
Examples found in repository?
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
fn encode(&self, buf: &mut dyn Write, default_decor: (&str, &str)) -> Result {
write!(buf, "{}[", self.decor().prefix().unwrap_or(default_decor.0))?;
for (i, elem) in self.iter().enumerate() {
let inner_decor;
if i == 0 {
inner_decor = DEFAULT_LEADING_VALUE_DECOR;
} else {
inner_decor = DEFAULT_VALUE_DECOR;
write!(buf, ",")?;
}
elem.encode(buf, inner_decor)?;
}
if self.trailing_comma() && !self.is_empty() {
write!(buf, ",")?;
}
write!(buf, "{}", self.trailing())?;
write!(buf, "]{}", self.decor().suffix().unwrap_or(default_decor.1))
}
sourcepub fn set_trailing(&mut self, trailing: &str)
pub fn set_trailing(&mut self, trailing: &str)
Set whitespace after last element
Examples found in repository?
31 32 33 34 35 36 37 38 39 40 41 42 43 44
fn visit_array_mut(&mut self, node: &mut crate::Array) {
crate::visit_mut::visit_array_mut(self, node);
if (0..=1).contains(&node.len()) {
node.set_trailing("");
node.set_trailing_comma(false);
} else {
for item in node.iter_mut() {
item.decor_mut().set_prefix("\n ");
}
node.set_trailing("\n");
node.set_trailing_comma(true);
}
}
More examples
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374
fn decorate_array(array: &mut Array) {
for (i, value) in array
.values
.iter_mut()
.filter_map(Item::as_value_mut)
.enumerate()
{
// [value1, value2, value3]
if i == 0 {
value.decorate(DEFAULT_LEADING_VALUE_DECOR.0, DEFAULT_LEADING_VALUE_DECOR.1);
} else {
value.decorate(DEFAULT_VALUE_DECOR.0, DEFAULT_VALUE_DECOR.1);
}
}
// Since everything is now on the same line, remove trailing commas and whitespace.
array.set_trailing_comma(false);
array.set_trailing("");
}
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
pub(crate) fn array_values(input: Input<'_>) -> IResult<Input<'_>, Array, ParserError<'_>> {
(
opt(
(separated_list1(ARRAY_SEP, array_value), opt(ARRAY_SEP)).map(
|(v, trailing): (Vec<Value>, Option<u8>)| {
(
Array::with_vec(v.into_iter().map(Item::Value).collect()),
trailing.is_some(),
)
},
),
),
ws_comment_newline,
)
.map_res::<_, _, std::str::Utf8Error>(|(array, trailing)| {
let (mut array, comma) = array.unwrap_or_default();
array.set_trailing_comma(comma);
array.set_trailing(std::str::from_utf8(trailing)?);
Ok(array)
})
.parse(input)
}
sourcepub fn trailing(&self) -> &str
pub fn trailing(&self) -> &str
Whitespace after last element
Examples found in repository?
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
fn encode(&self, buf: &mut dyn Write, default_decor: (&str, &str)) -> Result {
write!(buf, "{}[", self.decor().prefix().unwrap_or(default_decor.0))?;
for (i, elem) in self.iter().enumerate() {
let inner_decor;
if i == 0 {
inner_decor = DEFAULT_LEADING_VALUE_DECOR;
} else {
inner_decor = DEFAULT_VALUE_DECOR;
write!(buf, ",")?;
}
elem.encode(buf, inner_decor)?;
}
if self.trailing_comma() && !self.is_empty() {
write!(buf, ",")?;
}
write!(buf, "{}", self.trailing())?;
write!(buf, "]{}", self.decor().suffix().unwrap_or(default_decor.1))
}
sourcepub fn decor(&self) -> &Decor
pub fn decor(&self) -> &Decor
Returns the surrounding whitespace
Examples found in repository?
More examples
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
fn encode(&self, buf: &mut dyn Write, default_decor: (&str, &str)) -> Result {
write!(buf, "{}[", self.decor().prefix().unwrap_or(default_decor.0))?;
for (i, elem) in self.iter().enumerate() {
let inner_decor;
if i == 0 {
inner_decor = DEFAULT_LEADING_VALUE_DECOR;
} else {
inner_decor = DEFAULT_VALUE_DECOR;
write!(buf, ",")?;
}
elem.encode(buf, inner_decor)?;
}
if self.trailing_comma() && !self.is_empty() {
write!(buf, ",")?;
}
write!(buf, "{}", self.trailing())?;
write!(buf, "]{}", self.decor().suffix().unwrap_or(default_decor.1))
}
source§impl Array
impl Array
sourcepub fn iter(&self) -> ArrayIter<'_>
pub fn iter(&self) -> ArrayIter<'_>
Returns an iterator over all values.
Examples found in repository?
More examples
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
fn encode(&self, buf: &mut dyn Write, default_decor: (&str, &str)) -> Result {
write!(buf, "{}[", self.decor().prefix().unwrap_or(default_decor.0))?;
for (i, elem) in self.iter().enumerate() {
let inner_decor;
if i == 0 {
inner_decor = DEFAULT_LEADING_VALUE_DECOR;
} else {
inner_decor = DEFAULT_VALUE_DECOR;
write!(buf, ",")?;
}
elem.encode(buf, inner_decor)?;
}
if self.trailing_comma() && !self.is_empty() {
write!(buf, ",")?;
}
write!(buf, "{}", self.trailing())?;
write!(buf, "]{}", self.decor().suffix().unwrap_or(default_decor.1))
}
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
pub fn into_array_of_tables(self) -> Result<ArrayOfTables, Self> {
match self {
Item::ArrayOfTables(a) => Ok(a),
Item::Value(Value::Array(a)) => {
if a.is_empty() {
Err(Item::Value(Value::Array(a)))
} else if a.iter().all(|v| v.is_inline_table()) {
let mut aot = ArrayOfTables::new();
aot.values = a.values;
for value in aot.values.iter_mut() {
value.make_item();
}
Ok(aot)
} else {
Err(Item::Value(Value::Array(a)))
}
}
_ => Err(self),
}
}
sourcepub fn iter_mut(&mut self) -> ArrayIterMut<'_>
pub fn iter_mut(&mut self) -> ArrayIterMut<'_>
Returns an iterator over all values.
Examples found in repository?
More examples
31 32 33 34 35 36 37 38 39 40 41 42 43 44
fn visit_array_mut(&mut self, node: &mut crate::Array) {
crate::visit_mut::visit_array_mut(self, node);
if (0..=1).contains(&node.len()) {
node.set_trailing("");
node.set_trailing_comma(false);
} else {
for item in node.iter_mut() {
item.decor_mut().set_prefix("\n ");
}
node.set_trailing("\n");
node.set_trailing_comma(true);
}
}
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the length of the underlying Vec.
In some rare cases, placeholder elements will exist. For a more accurate count, call
a.iter().count()
Examples
let mut arr = toml_edit::Array::new();
arr.push(1);
arr.push("foo");
assert_eq!(arr.len(), 2);
Examples found in repository?
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
pub fn is_empty(&self) -> bool {
self.len() == 0
}
/// Clears the array, removing all values. Keeps the allocated memory for reuse.
pub fn clear(&mut self) {
self.values.clear()
}
/// Returns a reference to the value at the given index, or `None` if the index is out of
/// bounds.
pub fn get(&self, index: usize) -> Option<&Value> {
self.values.get(index).and_then(Item::as_value)
}
/// Returns a reference to the value at the given index, or `None` if the index is out of
/// bounds.
pub fn get_mut(&mut self, index: usize) -> Option<&mut Value> {
self.values.get_mut(index).and_then(Item::as_value_mut)
}
/// Appends a new value to the end of the array, applying default formatting to it.
///
/// # Examples
///
/// ```rust
/// let mut arr = toml_edit::Array::new();
/// arr.push(1);
/// arr.push("foo");
/// ```
pub fn push<V: Into<Value>>(&mut self, v: V) {
self.value_op(v.into(), true, |items, value| {
items.push(Item::Value(value))
})
}
/// Appends a new, already formatted value to the end of the array.
///
/// # Examples
///
/// ```rust
/// let formatted_value = "'literal'".parse::<toml_edit::Value>().unwrap();
/// let mut arr = toml_edit::Array::new();
/// arr.push_formatted(formatted_value);
/// ```
pub fn push_formatted(&mut self, v: Value) {
self.values.push(Item::Value(v));
}
/// Inserts an element at the given position within the array, applying default formatting to
/// it and shifting all values after it to the right.
///
/// # Panics
///
/// Panics if `index > len`.
///
/// # Examples
///
/// ```rust
/// let mut arr = toml_edit::Array::new();
/// arr.push(1);
/// arr.push("foo");
///
/// arr.insert(0, "start");
/// ```
pub fn insert<V: Into<Value>>(&mut self, index: usize, v: V) {
self.value_op(v.into(), true, |items, value| {
items.insert(index, Item::Value(value))
})
}
/// Inserts an already formatted value at the given position within the array, shifting all
/// values after it to the right.
///
/// # Panics
///
/// Panics if `index > len`.
///
/// # Examples
///
/// ```rust
/// let mut arr = toml_edit::Array::new();
/// arr.push(1);
/// arr.push("foo");
///
/// let formatted_value = "'start'".parse::<toml_edit::Value>().unwrap();
/// arr.insert_formatted(0, formatted_value);
/// ```
pub fn insert_formatted(&mut self, index: usize, v: Value) {
self.values.insert(index, Item::Value(v))
}
/// Replaces the element at the given position within the array, preserving existing formatting.
///
/// # Panics
///
/// Panics if `index >= len`.
///
/// # Examples
///
/// ```rust
/// let mut arr = toml_edit::Array::new();
/// arr.push(1);
/// arr.push("foo");
///
/// arr.replace(0, "start");
/// ```
pub fn replace<V: Into<Value>>(&mut self, index: usize, v: V) -> Value {
// Read the existing value's decor and preserve it.
let existing_decor = self
.get(index)
.unwrap_or_else(|| panic!("index {} out of bounds (len = {})", index, self.len()))
.decor();
let mut value = v.into();
*value.decor_mut() = existing_decor.clone();
self.replace_formatted(index, value)
}
More examples
31 32 33 34 35 36 37 38 39 40 41 42 43 44
fn visit_array_mut(&mut self, node: &mut crate::Array) {
crate::visit_mut::visit_array_mut(self, node);
if (0..=1).contains(&node.len()) {
node.set_trailing("");
node.set_trailing_comma(false);
} else {
for item in node.iter_mut() {
item.decor_mut().set_prefix("\n ");
}
node.set_trailing("\n");
node.set_trailing_comma(true);
}
}
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Return true iff self.len() == 0
.
Examples
let mut arr = toml_edit::Array::new();
assert!(arr.is_empty());
arr.push(1);
arr.push("foo");
assert!(! arr.is_empty());
Examples found in repository?
291 292 293 294 295 296 297 298 299 300 301 302 303 304
fn value_op<T>(
&mut self,
v: Value,
decorate: bool,
op: impl FnOnce(&mut Vec<Item>, Value) -> T,
) -> T {
let mut value = v;
if !self.is_empty() && decorate {
value.decorate(" ", "");
} else if decorate {
value.decorate("", "");
}
op(&mut self.values, value)
}
More examples
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
fn encode(&self, buf: &mut dyn Write, default_decor: (&str, &str)) -> Result {
write!(buf, "{}[", self.decor().prefix().unwrap_or(default_decor.0))?;
for (i, elem) in self.iter().enumerate() {
let inner_decor;
if i == 0 {
inner_decor = DEFAULT_LEADING_VALUE_DECOR;
} else {
inner_decor = DEFAULT_VALUE_DECOR;
write!(buf, ",")?;
}
elem.encode(buf, inner_decor)?;
}
if self.trailing_comma() && !self.is_empty() {
write!(buf, ",")?;
}
write!(buf, "{}", self.trailing())?;
write!(buf, "]{}", self.decor().suffix().unwrap_or(default_decor.1))
}
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
pub fn into_array_of_tables(self) -> Result<ArrayOfTables, Self> {
match self {
Item::ArrayOfTables(a) => Ok(a),
Item::Value(Value::Array(a)) => {
if a.is_empty() {
Err(Item::Value(Value::Array(a)))
} else if a.iter().all(|v| v.is_inline_table()) {
let mut aot = ArrayOfTables::new();
aot.values = a.values;
for value in aot.values.iter_mut() {
value.make_item();
}
Ok(aot)
} else {
Err(Item::Value(Value::Array(a)))
}
}
_ => Err(self),
}
}
sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clears the array, removing all values. Keeps the allocated memory for reuse.
sourcepub fn get(&self, index: usize) -> Option<&Value>
pub fn get(&self, index: usize) -> Option<&Value>
Returns a reference to the value at the given index, or None
if the index is out of
bounds.
sourcepub fn get_mut(&mut self, index: usize) -> Option<&mut Value>
pub fn get_mut(&mut self, index: usize) -> Option<&mut Value>
Returns a reference to the value at the given index, or None
if the index is out of
bounds.
sourcepub fn push<V: Into<Value>>(&mut self, v: V)
pub fn push<V: Into<Value>>(&mut self, v: V)
Appends a new value to the end of the array, applying default formatting to it.
Examples
let mut arr = toml_edit::Array::new();
arr.push(1);
arr.push("foo");
sourcepub fn push_formatted(&mut self, v: Value)
pub fn push_formatted(&mut self, v: Value)
Appends a new, already formatted value to the end of the array.
Examples
let formatted_value = "'literal'".parse::<toml_edit::Value>().unwrap();
let mut arr = toml_edit::Array::new();
arr.push_formatted(formatted_value);
sourcepub fn insert_formatted(&mut self, index: usize, v: Value)
pub fn insert_formatted(&mut self, index: usize, v: Value)
Inserts an already formatted value at the given position within the array, shifting all values after it to the right.
Panics
Panics if index > len
.
Examples
let mut arr = toml_edit::Array::new();
arr.push(1);
arr.push("foo");
let formatted_value = "'start'".parse::<toml_edit::Value>().unwrap();
arr.insert_formatted(0, formatted_value);
sourcepub fn replace_formatted(&mut self, index: usize, v: Value) -> Value
pub fn replace_formatted(&mut self, index: usize, v: Value) -> Value
Replaces the element at the given position within the array with an already formatted value.
Panics
Panics if index >= len
.
Examples
let mut arr = toml_edit::Array::new();
arr.push(1);
arr.push("foo");
let formatted_value = "'start'".parse::<toml_edit::Value>().unwrap();
arr.replace_formatted(0, formatted_value);
Trait Implementations§
source§impl<'de> Deserializer<'de> for Array
impl<'de> Deserializer<'de> for Array
source§fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserializer
to figure out how to drive the visitor based
on what data type is in the input. Read moresource§fn deserialize_bool<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_bool<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize
type is expecting a bool
value.source§fn deserialize_u8<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_u8<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize
type is expecting a u8
value.source§fn deserialize_u16<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_u16<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize
type is expecting a u16
value.source§fn deserialize_u32<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_u32<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize
type is expecting a u32
value.source§fn deserialize_u64<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_u64<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize
type is expecting a u64
value.source§fn deserialize_i8<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_i8<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize
type is expecting an i8
value.source§fn deserialize_i16<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_i16<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize
type is expecting an i16
value.source§fn deserialize_i32<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_i32<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize
type is expecting an i32
value.source§fn deserialize_i64<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_i64<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize
type is expecting an i64
value.source§fn deserialize_f32<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_f32<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize
type is expecting a f32
value.source§fn deserialize_f64<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_f64<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize
type is expecting a f64
value.source§fn deserialize_char<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_char<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize
type is expecting a char
value.source§fn deserialize_str<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_str<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize
type is expecting a string value and does
not benefit from taking ownership of buffered data owned by the
Deserializer
. Read moresource§fn deserialize_string<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_string<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize
type is expecting a string value and would
benefit from taking ownership of buffered data owned by the
Deserializer
. Read moresource§fn deserialize_seq<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_seq<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize
type is expecting a sequence of values.source§fn deserialize_bytes<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_bytes<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize
type is expecting a byte array and does not
benefit from taking ownership of buffered data owned by the
Deserializer
. Read moresource§fn deserialize_byte_buf<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_byte_buf<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize
type is expecting a byte array and would
benefit from taking ownership of buffered data owned by the
Deserializer
. Read moresource§fn deserialize_map<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_map<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize
type is expecting a map of key-value pairs.source§fn deserialize_option<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_option<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize
type is expecting an optional value. Read moresource§fn deserialize_unit<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_unit<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize
type is expecting a unit value.source§fn deserialize_newtype_struct<V>(
self,
name: &'static str,
visitor: V
) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_newtype_struct<V>(
self,
name: &'static str,
visitor: V
) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize
type is expecting a newtype struct with a
particular name.source§fn deserialize_ignored_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_ignored_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize
type needs to deserialize a value whose type
doesn’t matter because it is ignored. Read moresource§fn deserialize_unit_struct<V>(
self,
name: &'static str,
visitor: V
) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_unit_struct<V>(
self,
name: &'static str,
visitor: V
) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize
type is expecting a unit struct with a
particular name.source§fn deserialize_tuple_struct<V>(
self,
name: &'static str,
len: usize,
visitor: V
) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_tuple_struct<V>(
self,
name: &'static str,
len: usize,
visitor: V
) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize
type is expecting a tuple struct with a
particular name and number of fields.source§fn deserialize_tuple<V>(
self,
len: usize,
visitor: V
) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_tuple<V>(
self,
len: usize,
visitor: V
) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize
type is expecting a sequence of values and
knows how many values there are without looking at the serialized data.source§fn deserialize_enum<V>(
self,
name: &'static str,
variants: &'static [&'static str],
visitor: V
) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_enum<V>(
self,
name: &'static str,
variants: &'static [&'static str],
visitor: V
) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize
type is expecting an enum value with a
particular name and possible variants.source§fn deserialize_identifier<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_identifier<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize
type is expecting the name of a struct
field or the discriminant of an enum variant.source§fn deserialize_struct<V>(
self,
name: &'static str,
fields: &'static [&'static str],
visitor: V
) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_struct<V>(
self,
name: &'static str,
fields: &'static [&'static str],
visitor: V
) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize
type is expecting a struct with a particular
name and fields.source§fn deserialize_i128<V>(
self,
visitor: V
) -> Result<<V as Visitor<'de>>::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_i128<V>(
self,
visitor: V
) -> Result<<V as Visitor<'de>>::Value, Self::Error>where
V: Visitor<'de>,
source§fn deserialize_u128<V>(
self,
visitor: V
) -> Result<<V as Visitor<'de>>::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_u128<V>(
self,
visitor: V
) -> Result<<V as Visitor<'de>>::Value, Self::Error>where
V: Visitor<'de>,
source§fn is_human_readable(&self) -> bool
fn is_human_readable(&self) -> bool
Deserialize
implementations should expect to
deserialize their human-readable form. Read moresource§impl<V: Into<Value>> Extend<V> for Array
impl<V: Into<Value>> Extend<V> for Array
source§fn extend<T: IntoIterator<Item = V>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = V>>(&mut self, iter: T)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)