pub struct DocumentShapeDeserializer<'a> { /* private fields */ }Expand description
Walks a [Document] tree via the ShapeDeserializer interface.
See the module-level documentation for an overview.
§Example
Use DiscriminatedDocument::as_shape
for the common case of consuming a DiscriminatedDocument
via a generated deserialize method:
use aws_smithy_schema::document::DiscriminatedDocumentExt;
let person: Person = doc.as_shape(|deser| Person::deserialize(deser))?;Direct construction is useful when consuming a sub-document outside the standard entry point:
use aws_smithy_schema::document::DocumentShapeDeserializer;
use aws_smithy_schema::serde::ShapeDeserializer;
let mut deser = DocumentShapeDeserializer::new(&doc);
let s = deser.read_string(&aws_smithy_schema::prelude::STRING)?;Implementations§
Source§impl<'a> DocumentShapeDeserializer<'a>
impl<'a> DocumentShapeDeserializer<'a>
Sourcepub fn new(document: &'a Document) -> Self
pub fn new(document: &'a Document) -> Self
Creates a deserializer positioned at the given document.
The lifetime parameter is the borrow lifetime of document —
the cursor is just a &Document. [Document] itself has no
lifetime parameter (it is fully owned), so this 'a is purely
the per-call borrow lifetime.
No format-aware coercion is performed; this deserializer is
variant-only. For coercion of wire-encoded blobs and timestamps
(e.g. JSON’s base64-string blobs, epoch-seconds-number
timestamps), use Self::new_with_settings.
Sourcepub fn new_with_settings(
document: &'a Document,
settings: Option<Arc<dyn DocumentSettings>>,
) -> Self
pub fn new_with_settings( document: &'a Document, settings: Option<Arc<dyn DocumentSettings>>, ) -> Self
Creates a deserializer positioned at the given document with codec settings attached.
With settings present, Self::read_blob and
Self::read_timestamp consult the settings to coerce
non-native variants — JSON wire bytes encode blobs as
base64 strings and may encode timestamps as strings or
numbers, so a document parsed from JSON via
crate::codec::Codec::create_deserializer needs settings
for those round-trips to succeed.
Trait Implementations§
Source§impl<'a> Debug for DocumentShapeDeserializer<'a>
impl<'a> Debug for DocumentShapeDeserializer<'a>
Source§impl<'a> ShapeDeserializer for DocumentShapeDeserializer<'a>
impl<'a> ShapeDeserializer for DocumentShapeDeserializer<'a>
Source§fn skip_value(&mut self) -> Result<(), SerdeError>
fn skip_value(&mut self) -> Result<(), SerdeError>
Nothing to advance. The cursor points at an already-parsed node of an owned
document tree, and read_struct hands each member its own sub-deserializer, so
declining a value has no effect on the parent’s iteration.
Source§fn read_struct(
&mut self,
schema: &Schema<'_>,
consumer: &mut dyn FnMut(&Schema<'_>, &mut dyn ShapeDeserializer) -> Result<(), SerdeError>,
) -> Result<(), SerdeError>
fn read_struct( &mut self, schema: &Schema<'_>, consumer: &mut dyn FnMut(&Schema<'_>, &mut dyn ShapeDeserializer) -> Result<(), SerdeError>, ) -> Result<(), SerdeError>
Source§fn read_list(
&mut self,
_schema: &Schema<'_>,
consumer: &mut dyn FnMut(&mut dyn ShapeDeserializer) -> Result<(), SerdeError>,
) -> Result<(), SerdeError>
fn read_list( &mut self, _schema: &Schema<'_>, consumer: &mut dyn FnMut(&mut dyn ShapeDeserializer) -> Result<(), SerdeError>, ) -> Result<(), SerdeError>
Source§fn read_map(
&mut self,
_schema: &Schema<'_>,
consumer: &mut dyn FnMut(String, &mut dyn ShapeDeserializer) -> Result<(), SerdeError>,
) -> Result<(), SerdeError>
fn read_map( &mut self, _schema: &Schema<'_>, consumer: &mut dyn FnMut(String, &mut dyn ShapeDeserializer) -> Result<(), SerdeError>, ) -> Result<(), SerdeError>
Source§fn read_boolean(&mut self, _schema: &Schema<'_>) -> Result<bool, SerdeError>
fn read_boolean(&mut self, _schema: &Schema<'_>) -> Result<bool, SerdeError>
Source§fn read_byte(&mut self, _schema: &Schema<'_>) -> Result<i8, SerdeError>
fn read_byte(&mut self, _schema: &Schema<'_>) -> Result<i8, SerdeError>
Source§fn read_short(&mut self, _schema: &Schema<'_>) -> Result<i16, SerdeError>
fn read_short(&mut self, _schema: &Schema<'_>) -> Result<i16, SerdeError>
Source§fn read_integer(&mut self, _schema: &Schema<'_>) -> Result<i32, SerdeError>
fn read_integer(&mut self, _schema: &Schema<'_>) -> Result<i32, SerdeError>
Source§fn read_long(&mut self, _schema: &Schema<'_>) -> Result<i64, SerdeError>
fn read_long(&mut self, _schema: &Schema<'_>) -> Result<i64, SerdeError>
Source§fn read_float(&mut self, _schema: &Schema<'_>) -> Result<f32, SerdeError>
fn read_float(&mut self, _schema: &Schema<'_>) -> Result<f32, SerdeError>
Source§fn read_double(&mut self, _schema: &Schema<'_>) -> Result<f64, SerdeError>
fn read_double(&mut self, _schema: &Schema<'_>) -> Result<f64, SerdeError>
Source§fn read_big_integer(
&mut self,
_schema: &Schema<'_>,
) -> Result<BigInteger, SerdeError>
fn read_big_integer( &mut self, _schema: &Schema<'_>, ) -> Result<BigInteger, SerdeError>
Source§fn read_big_decimal(
&mut self,
_schema: &Schema<'_>,
) -> Result<BigDecimal, SerdeError>
fn read_big_decimal( &mut self, _schema: &Schema<'_>, ) -> Result<BigDecimal, SerdeError>
Source§fn read_string(&mut self, _schema: &Schema<'_>) -> Result<String, SerdeError>
fn read_string(&mut self, _schema: &Schema<'_>) -> Result<String, SerdeError>
Source§fn read_blob(&mut self, _schema: &Schema<'_>) -> Result<Blob, SerdeError>
fn read_blob(&mut self, _schema: &Schema<'_>) -> Result<Blob, SerdeError>
Source§fn read_timestamp(
&mut self,
_schema: &Schema<'_>,
) -> Result<DateTime, SerdeError>
fn read_timestamp( &mut self, _schema: &Schema<'_>, ) -> Result<DateTime, SerdeError>
Source§fn read_document(
&mut self,
_schema: &Schema<'_>,
) -> Result<Document, SerdeError>
fn read_document( &mut self, _schema: &Schema<'_>, ) -> Result<Document, SerdeError>
Source§fn container_size(&self) -> Option<usize>
fn container_size(&self) -> Option<usize>
Source§fn read_null(&mut self) -> Result<(), SerdeError>
fn read_null(&mut self) -> Result<(), SerdeError>
Source§fn read_string_list(
&mut self,
schema: &Schema<'_>,
) -> Result<Vec<String>, SerdeError>
fn read_string_list( &mut self, schema: &Schema<'_>, ) -> Result<Vec<String>, SerdeError>
Source§fn read_blob_list(
&mut self,
schema: &Schema<'_>,
) -> Result<Vec<Blob>, SerdeError>
fn read_blob_list( &mut self, schema: &Schema<'_>, ) -> Result<Vec<Blob>, SerdeError>
Source§fn read_integer_list(
&mut self,
schema: &Schema<'_>,
) -> Result<Vec<i32>, SerdeError>
fn read_integer_list( &mut self, schema: &Schema<'_>, ) -> Result<Vec<i32>, SerdeError>
Source§fn read_long_list(
&mut self,
schema: &Schema<'_>,
) -> Result<Vec<i64>, SerdeError>
fn read_long_list( &mut self, schema: &Schema<'_>, ) -> Result<Vec<i64>, SerdeError>
Source§fn read_string_string_map(
&mut self,
schema: &Schema<'_>,
) -> Result<HashMap<String, String>, SerdeError>
fn read_string_string_map( &mut self, schema: &Schema<'_>, ) -> Result<HashMap<String, String>, SerdeError>
Auto Trait Implementations§
impl<'a> Freeze for DocumentShapeDeserializer<'a>
impl<'a> !RefUnwindSafe for DocumentShapeDeserializer<'a>
impl<'a> Send for DocumentShapeDeserializer<'a>
impl<'a> Sync for DocumentShapeDeserializer<'a>
impl<'a> Unpin for DocumentShapeDeserializer<'a>
impl<'a> UnsafeUnpin for DocumentShapeDeserializer<'a>
impl<'a> !UnwindSafe for DocumentShapeDeserializer<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more