-
Notifications
You must be signed in to change notification settings - Fork 53
feat(sdk): auto-detect protocol version from network response metadata #3483
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
Changes from all commits
7548871
acf0e6e
036ba3b
2624d3a
218f474
7859df4
6d59358
b01969d
1085027
99ccac7
517594e
37de63b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -11,8 +11,8 @@ impl Serialize for DataContract { | |||||||||||||||||||||
| where | ||||||||||||||||||||||
| S: Serializer, | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| let current_version = | ||||||||||||||||||||||
| PlatformVersion::get_current().map_err(|e| serde::ser::Error::custom(e.to_string()))?; | ||||||||||||||||||||||
| let current_version = PlatformVersion::get_version_or_current_or_latest(None) | ||||||||||||||||||||||
| .map_err(|e| serde::ser::Error::custom(e.to_string()))?; | ||||||||||||||||||||||
| let data_contract_in_serialization_format: DataContractInSerializationFormat = self | ||||||||||||||||||||||
| .try_into_platform_versioned(current_version) | ||||||||||||||||||||||
| .map_err(|e: ProtocolError| serde::ser::Error::custom(format!("expected to be able to serialize data contract into its serialized version: {}", e)))?; | ||||||||||||||||||||||
|
|
@@ -26,12 +26,8 @@ impl<'de> Deserialize<'de> for DataContract { | |||||||||||||||||||||
| D: Deserializer<'de>, | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| let serialization_format = DataContractInSerializationFormat::deserialize(deserializer)?; | ||||||||||||||||||||||
| let current_version = PlatformVersion::get_current().map_err(|e| { | ||||||||||||||||||||||
| serde::de::Error::custom(format!( | ||||||||||||||||||||||
| "expected to be able to get current platform version: {}", | ||||||||||||||||||||||
| e | ||||||||||||||||||||||
| )) | ||||||||||||||||||||||
| })?; | ||||||||||||||||||||||
| let current_version = PlatformVersion::get_version_or_current_or_latest(None) | ||||||||||||||||||||||
| .map_err(|e| serde::de::Error::custom(e.to_string()))?; | ||||||||||||||||||||||
|
Comment on lines
+29
to
+30
|
||||||||||||||||||||||
| let current_version = PlatformVersion::get_version_or_current_or_latest(None) | |
| .map_err(|e| serde::de::Error::custom(e.to_string()))?; | |
| let current_version = PlatformVersion::get_version_or_current_or_latest(None).map_err( | |
| |e| { | |
| serde::de::Error::custom(format!( | |
| "failed to resolve platform version for DataContract deserialization: {}", | |
| e | |
| )) | |
| }, | |
| )?; |
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.
In
Serialize, mapping the platform-version resolution error toe.to_string()drops useful context about what failed (platform version resolution vs contract conversion). Consider wrapping the error with a brief prefix so debugging serde failures is easier.