-
Notifications
You must be signed in to change notification settings - Fork 10
fix: Vec<u8> for potentially non-ascii data #323
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
Draft
joe-p
wants to merge
20
commits into
main
Choose a base branch
from
fix/block_logs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 5 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
f1422c3
fix: logs as Vec<u8> instead of String
joe-p 59f0c1b
fix: delta values as Vec<u8>
joe-p 6f7ce6b
wip: test
joe-p afa4c9e
wip: t1
joe-p 85a5653
wip: lg
joe-p b380144
wip: try unsafe str
joe-p 5939ebf
wip: msgpack_string_bytes for logs
joe-p 287558e
wip: string_bytes_vec
joe-p 0cda72d
wip: default logs
joe-p 3b1f25d
wip: block state delta keys
joe-p 8746939
wip: NonAsciiString
joe-p 81a3988
wip: use NonAsciiString
joe-p 6798592
wip: NonAsciiString for block state delta
joe-p 15e44b3
wip: block cert
joe-p 3ecebb6
wip: rm lsig, optional oper
joe-p fd41c5a
wip: rm lsig from struct
joe-p 9ada1ff
wip: default u64 values
joe-p 2bcd30d
wip: handle empty vecs
joe-p 5e028d1
wip: serialize as str if possible
joe-p f46c1b6
wip: use rmp_serde::Raw
joe-p 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 hidden or 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 hidden or 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
39 changes: 39 additions & 0 deletions
39
api/oas_generator/rust_oas_generator/templates/base/msgpack_string_bytes.rs.j2
This file contains hidden or 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,39 @@ | ||
| /// Custom serde module for deserializing msgpack strings as raw bytes. | ||
| /// | ||
| /// Msgpack strings may contain arbitrary bytes that aren't valid UTF-8. | ||
| /// This module deserializes the raw string bytes into Vec<u8> without | ||
| /// requiring UTF-8 validity. | ||
| use serde::{Deserialize, Deserializer, Serializer}; | ||
|
|
||
| /// Deserialize a msgpack string as raw bytes | ||
| pub fn deserialize<'de, D>(deserializer: D) -> Result<Option<Vec<u8>>, D::Error> | ||
| where | ||
| D: Deserializer<'de>, | ||
| { | ||
| // Use rmpv::Value to capture the raw msgpack value | ||
| let value: Option<rmpv::Value> = Option::deserialize(deserializer)?; | ||
|
|
||
| match value { | ||
| Some(rmpv::Value::String(s)) => { | ||
| // rmpv::Utf8String gives us access to raw bytes even if not valid UTF-8 | ||
| Ok(Some(s.into_bytes())) | ||
| } | ||
| Some(rmpv::Value::Binary(b)) => Ok(Some(b)), | ||
| Some(_) => Err(serde::de::Error::custom( | ||
| "expected string or binary, got other type", | ||
| )), | ||
| None => Ok(None), | ||
| } | ||
| } | ||
|
|
||
| /// Serialize bytes as a msgpack binary | ||
| pub fn serialize<S>(value: &Option<Vec<u8>>, serializer: S) -> Result<S::Ok, S::Error> | ||
| where | ||
| S: Serializer, | ||
| { | ||
| match value { | ||
| Some(bytes) => serializer.serialize_bytes(bytes), | ||
| None => serializer.serialize_none(), | ||
| } | ||
| } | ||
|
|
This file contains hidden or 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
57 changes: 0 additions & 57 deletions
57
...as_generator/rust_oas_generator/templates/models/block/block_application_eval_delta.rs.j2
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.