-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor aws smithy types #2638
Merged
Velfi
merged 8 commits into
smithy-lang:main
from
thomas-k-cameron:refactor-aws-smithy-types
Apr 26, 2023
+556
−537
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b716133
refactor
thomas-k-cameron a5662c0
chore: update CHANGELOG.next.toml
thomas-k-cameron 8d78cc2
Merge branch 'main' into refactor-aws-smithy-types
thomas-k-cameron deeaaef
Update CHANGELOG.next.toml
thomas-k-cameron 3fd99b3
Update CHANGELOG.next.toml
thomas-k-cameron d4eddae
Update CHANGELOG.next.toml
thomas-k-cameron 9d7e8d2
FIX precommit
thomas-k-cameron 468ce35
FIX
thomas-k-cameron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/// Binary Blob Type | ||
/// | ||
/// Blobs represent protocol-agnostic binary content. | ||
#[derive(Debug, PartialEq, Eq, Hash, Clone)] | ||
pub struct Blob { | ||
inner: Vec<u8>, | ||
} | ||
|
||
impl Blob { | ||
/// Creates a new blob from the given `input`. | ||
pub fn new<T: Into<Vec<u8>>>(input: T) -> Self { | ||
Blob { | ||
inner: input.into(), | ||
} | ||
} | ||
|
||
/// Consumes the `Blob` and returns a `Vec<u8>` with its contents. | ||
pub fn into_inner(self) -> Vec<u8> { | ||
self.inner | ||
} | ||
} | ||
|
||
impl AsRef<[u8]> for Blob { | ||
fn as_ref(&self) -> &[u8] { | ||
&self.inner | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
use crate::Number; | ||
use std::collections::HashMap; | ||
|
||
/* ANCHOR: document */ | ||
|
||
/// Document Type | ||
/// | ||
/// Document types represents protocol-agnostic open content that is accessed like JSON data. | ||
/// Open content is useful for modeling unstructured data that has no schema, data that can't be | ||
/// modeled using rigid types, or data that has a schema that evolves outside of the purview of a model. | ||
/// The serialization format of a document is an implementation detail of a protocol. | ||
#[derive(Debug, Clone, PartialEq)] | ||
pub enum Document { | ||
/// JSON object | ||
Object(HashMap<String, Document>), | ||
/// JSON array | ||
Array(Vec<Document>), | ||
/// JSON number | ||
Number(Number), | ||
/// JSON string | ||
String(String), | ||
/// JSON boolean | ||
Bool(bool), | ||
/// JSON null | ||
Null, | ||
} | ||
|
||
impl From<bool> for Document { | ||
fn from(value: bool) -> Self { | ||
Document::Bool(value) | ||
} | ||
} | ||
|
||
impl From<String> for Document { | ||
fn from(value: String) -> Self { | ||
Document::String(value) | ||
} | ||
} | ||
|
||
impl From<Vec<Document>> for Document { | ||
fn from(values: Vec<Document>) -> Self { | ||
Document::Array(values) | ||
} | ||
} | ||
|
||
impl From<HashMap<String, Document>> for Document { | ||
fn from(values: HashMap<String, Document>) -> Self { | ||
Document::Object(values) | ||
} | ||
} | ||
|
||
impl From<u64> for Document { | ||
fn from(value: u64) -> Self { | ||
Document::Number(Number::PosInt(value)) | ||
} | ||
} | ||
|
||
impl From<i64> for Document { | ||
fn from(value: i64) -> Self { | ||
Document::Number(Number::NegInt(value)) | ||
} | ||
} | ||
|
||
impl From<i32> for Document { | ||
fn from(value: i32) -> Self { | ||
Document::Number(Number::NegInt(value as i64)) | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes don't change the public API in any way, right? If so, I don't think we need these changelog entries. I'm also not sure about why the
"bug" = true
either 🤔There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it doesn't change the API.
I thought that I have to mention refactoring too.
This one is simple mistake on my side.
Thank you for letting me know. Let me fix it up.