mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-23 00:08:01 +00:00
Merge branch 'skip_deserializing' of https://github.com/dtolnay/serde into dtolnay-skip_deserializing
This commit is contained in:
@@ -176,6 +176,7 @@ impl VariantAttrs {
|
||||
pub struct FieldAttrs {
|
||||
name: Name,
|
||||
skip_serializing_field: bool,
|
||||
skip_deserializing_field: bool,
|
||||
skip_serializing_field_if: Option<P<ast::Expr>>,
|
||||
default_expr_if_missing: Option<P<ast::Expr>>,
|
||||
serialize_with: Option<P<ast::Expr>>,
|
||||
@@ -199,6 +200,7 @@ impl FieldAttrs {
|
||||
let mut field_attrs = FieldAttrs {
|
||||
name: Name::new(field_ident),
|
||||
skip_serializing_field: false,
|
||||
skip_deserializing_field: false,
|
||||
skip_serializing_field_if: None,
|
||||
default_expr_if_missing: None,
|
||||
serialize_with: None,
|
||||
@@ -244,6 +246,11 @@ impl FieldAttrs {
|
||||
field_attrs.skip_serializing_field = true;
|
||||
}
|
||||
|
||||
// Parse `#[serde(skip_deserializing)]`
|
||||
ast::MetaItemKind::Word(ref name) if name == &"skip_deserializing" => {
|
||||
field_attrs.skip_deserializing_field = true;
|
||||
}
|
||||
|
||||
// Parse `#[serde(skip_serializing_if="...")]`
|
||||
ast::MetaItemKind::NameValue(ref name, ref lit) if name == &"skip_serializing_if" => {
|
||||
let expr = wrap_skip_serializing(
|
||||
@@ -320,6 +327,10 @@ impl FieldAttrs {
|
||||
self.skip_serializing_field
|
||||
}
|
||||
|
||||
pub fn skip_deserializing_field(&self) -> bool {
|
||||
self.skip_deserializing_field
|
||||
}
|
||||
|
||||
pub fn skip_serializing_field_if(&self) -> Option<&P<ast::Expr>> {
|
||||
self.skip_serializing_field_if.as_ref()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user