Skip to main content

ShapeDeserializer

Trait ShapeDeserializer 

Source
pub trait ShapeDeserializer {
Show 25 methods // Required methods fn read_struct( &mut self, schema: &Schema<'_>, state: &mut dyn FnMut(&Schema<'_>, &mut dyn ShapeDeserializer) -> Result<(), SerdeError>, ) -> Result<(), SerdeError>; fn read_list( &mut self, schema: &Schema<'_>, state: &mut dyn FnMut(&mut dyn ShapeDeserializer) -> Result<(), SerdeError>, ) -> Result<(), SerdeError>; fn read_map( &mut self, schema: &Schema<'_>, state: &mut dyn FnMut(String, &mut dyn ShapeDeserializer) -> Result<(), SerdeError>, ) -> Result<(), SerdeError>; fn read_boolean(&mut self, schema: &Schema<'_>) -> Result<bool, SerdeError>; fn read_byte(&mut self, schema: &Schema<'_>) -> Result<i8, SerdeError>; fn read_short(&mut self, schema: &Schema<'_>) -> Result<i16, SerdeError>; fn read_integer(&mut self, schema: &Schema<'_>) -> Result<i32, SerdeError>; fn read_long(&mut self, schema: &Schema<'_>) -> Result<i64, SerdeError>; fn read_float(&mut self, schema: &Schema<'_>) -> Result<f32, SerdeError>; fn read_double(&mut self, schema: &Schema<'_>) -> Result<f64, SerdeError>; fn read_big_integer( &mut self, schema: &Schema<'_>, ) -> Result<BigInteger, SerdeError>; fn read_big_decimal( &mut self, schema: &Schema<'_>, ) -> Result<BigDecimal, SerdeError>; fn read_string(&mut self, schema: &Schema<'_>) -> Result<String, SerdeError>; fn read_blob(&mut self, schema: &Schema<'_>) -> Result<Blob, SerdeError>; fn read_timestamp( &mut self, schema: &Schema<'_>, ) -> Result<DateTime, SerdeError>; fn read_document( &mut self, schema: &Schema<'_>, ) -> Result<Document, SerdeError>; fn is_null(&self) -> bool; fn container_size(&self) -> Option<usize>; // Provided methods fn read_null(&mut self) -> Result<(), SerdeError> { ... } fn skip_value(&mut self) -> Result<(), SerdeError> { ... } fn read_string_list( &mut self, schema: &Schema<'_>, ) -> Result<Vec<String>, SerdeError> { ... } fn read_blob_list( &mut self, schema: &Schema<'_>, ) -> Result<Vec<Blob>, SerdeError> { ... } fn read_integer_list( &mut self, schema: &Schema<'_>, ) -> Result<Vec<i32>, SerdeError> { ... } fn read_long_list( &mut self, schema: &Schema<'_>, ) -> Result<Vec<i64>, SerdeError> { ... } fn read_string_string_map( &mut self, schema: &Schema<'_>, ) -> Result<HashMap<String, String>, SerdeError> { ... }
}
Expand description

Reads values of the Smithy data model from a serialized source, guided by a Schema.

This is the deserialization counterpart to ShapeSerializer: codecs implement it so a shape can be deserialized from any format without shape-specific code.

Required Methods§

Source

fn read_struct( &mut self, schema: &Schema<'_>, state: &mut dyn FnMut(&Schema<'_>, &mut dyn ShapeDeserializer) -> Result<(), SerdeError>, ) -> Result<(), SerdeError>

Reads a structure from the deserializer.

The consumer is called for each member with the member schema and a &mut dyn ShapeDeserializer to read the member value. Using dyn allows composite deserializers (e.g., HTTP binding + body) to transparently delegate without the consumer knowing the concrete type.

Source

fn read_list( &mut self, schema: &Schema<'_>, state: &mut dyn FnMut(&mut dyn ShapeDeserializer) -> Result<(), SerdeError>, ) -> Result<(), SerdeError>

Reads a list from the deserializer.

The consumer is called for each element with a &mut dyn ShapeDeserializer.

Source

fn read_map( &mut self, schema: &Schema<'_>, state: &mut dyn FnMut(String, &mut dyn ShapeDeserializer) -> Result<(), SerdeError>, ) -> Result<(), SerdeError>

Reads a map from the deserializer.

The consumer is called for each entry with the key and a &mut dyn ShapeDeserializer.

Source

fn read_boolean(&mut self, schema: &Schema<'_>) -> Result<bool, SerdeError>

Reads a boolean value.

Source

fn read_byte(&mut self, schema: &Schema<'_>) -> Result<i8, SerdeError>

Reads a byte (i8) value.

Source

fn read_short(&mut self, schema: &Schema<'_>) -> Result<i16, SerdeError>

Reads a short (i16) value.

Source

fn read_integer(&mut self, schema: &Schema<'_>) -> Result<i32, SerdeError>

Reads an integer (i32) value.

Source

fn read_long(&mut self, schema: &Schema<'_>) -> Result<i64, SerdeError>

Reads a long (i64) value.

Source

fn read_float(&mut self, schema: &Schema<'_>) -> Result<f32, SerdeError>

Reads a float (f32) value.

Source

fn read_double(&mut self, schema: &Schema<'_>) -> Result<f64, SerdeError>

Reads a double (f64) value.

Source

fn read_big_integer( &mut self, schema: &Schema<'_>, ) -> Result<BigInteger, SerdeError>

Reads a big integer value.

Source

fn read_big_decimal( &mut self, schema: &Schema<'_>, ) -> Result<BigDecimal, SerdeError>

Reads a big decimal value.

Source

fn read_string(&mut self, schema: &Schema<'_>) -> Result<String, SerdeError>

Reads a string value.

Source

fn read_blob(&mut self, schema: &Schema<'_>) -> Result<Blob, SerdeError>

Reads a blob (byte array) value.

Source

fn read_timestamp( &mut self, schema: &Schema<'_>, ) -> Result<DateTime, SerdeError>

Reads a timestamp value.

Source

fn read_document(&mut self, schema: &Schema<'_>) -> Result<Document, SerdeError>

Reads a document value.

Returns the [aws_smithy_types::Document] (fully owned, no lifetime). Implementations construct the value from their underlying source representation.

Source

fn is_null(&self) -> bool

Checks if the current value is null.

This is used for sparse collections where null values are significant.

Source

fn container_size(&self) -> Option<usize>

Returns the size of the current container if known.

This is an optimization hint that allows pre-allocating collections with the correct capacity. Returns None if the size is unknown or not applicable.

Implementations SHOULD cap the returned value at a reasonable maximum (e.g., 10,000) to prevent denial-of-service from untrusted payloads that claim excessively large container sizes (e.g., a CBOR header declaring billions of elements). Use capped_container_size to apply a standard cap.

Provided Methods§

Source

fn read_null(&mut self) -> Result<(), SerdeError>

Consumes a null value, advancing past it.

This should be called after is_null() returns true to advance the deserializer past the null token.

Source

fn skip_value(&mut self) -> Result<(), SerdeError>

Consumes the current value without interpreting it.

A consumer calls this when a value is present but must not be used. The motivating case is a protocol body that carries a field for a member whose authoritative value comes from elsewhere in the message — for example an HTTP response where the member is bound to a header or the status code. The transport value wins, so the body copy is consumed and discarded rather than being allowed to overwrite it.

§Implementor contract

The requirement is that after this returns, the parent aggregate read can continue correctly. What that takes depends on how the implementation hands values to a consumer, and the two cases are opposites:

  • Cursor-based formats (JSON, CBOR) position a single shared cursor at the value and rely on the consumer to move it. These MUST advance past the complete value, including all nested content. Failing to advance leaves the cursor mid-value and corrupts the rest of the parse.
  • Pre-isolated formats (XML, document trees, and single-value adapters) give the consumer a value the parent has already delimited, and the parent’s own iteration advances independently. These MUST NOT attempt a second advance, and so return Ok(()) without doing anything.

The default is a correctness fallback for third-party codecs that have not considered this method: it reads and drops a [Document], which advances a cursor-based codec correctly at the cost of an allocation. Implementations SHOULD override it. A codec that cannot produce documents will surface SerdeError::unsupported from the default, which is why the built-in deserializers all override it and never allocate here.

Source

fn read_string_list( &mut self, schema: &Schema<'_>, ) -> Result<Vec<String>, SerdeError>

Reads a list of strings.

Source

fn read_blob_list( &mut self, schema: &Schema<'_>, ) -> Result<Vec<Blob>, SerdeError>

Reads a list of blobs.

Source

fn read_integer_list( &mut self, schema: &Schema<'_>, ) -> Result<Vec<i32>, SerdeError>

Reads a list of integers.

Source

fn read_long_list( &mut self, schema: &Schema<'_>, ) -> Result<Vec<i64>, SerdeError>

Reads a list of longs.

Source

fn read_string_string_map( &mut self, schema: &Schema<'_>, ) -> Result<HashMap<String, String>, SerdeError>

Reads a map with string values.

Implementors§