Skip to content

Commit

Permalink
Allow Python specific Document type to be used in serialization and…
Browse files Browse the repository at this point in the history
… deserialization
  • Loading branch information
unexge committed Jan 10, 2023
1 parent 573386f commit b9601f8
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions rust-runtime/aws-smithy-http-server-python/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use std::{
collections::HashMap,
future::Future,
ops::Deref,
pin::Pin,
sync::Arc,
task::{Context, Poll},
Expand Down Expand Up @@ -493,6 +494,24 @@ impl FromPyObject<'_> for Document {
}
}

// TODO(PythonSerialization): Get rid of this hack.
// `JsonValueWriter::document` expects `&aws_smithy_types::Document`
// and this impl allows `&Document` to get coerced to `&aws_smithy_types::Document`.
// We should ideally handle this in `JsonSerializerGenerator.kt` but I'm not sure how hard it is.
impl Deref for Document {
type Target = aws_smithy_types::Document;

fn deref(&self) -> &Self::Target {
&self.0
}
}

impl From<aws_smithy_types::Document> for Document {
fn from(other: aws_smithy_types::Document) -> Document {
Document(other)
}
}

#[cfg(test)]
mod tests {
use pyo3::py_run;
Expand Down

0 comments on commit b9601f8

Please sign in to comment.