-
Notifications
You must be signed in to change notification settings - Fork 0
feat(rust/signed-doc): Catalyst Signed Documents minicbor::Decode
impl
#383
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
Merged
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
9095fd3
more tests
Mr-Leshiy a022823
add signatures decoding logic
Mr-Leshiy d661677
wip
Mr-Leshiy e682d01
wip
Mr-Leshiy 2283212
Merge branch 'feat/new-cat-signed-doc' into feat/decoder
Mr-Leshiy 813c9b8
wip
Mr-Leshiy befe239
wip
Mr-Leshiy 2225029
wip
Mr-Leshiy 8b19f4d
wip
Mr-Leshiy f0d29c1
Merge branch 'feat/new-cat-signed-doc' into feat/decoder
Mr-Leshiy fd8000d
wip
Mr-Leshiy 61a5a5f
wip
Mr-Leshiy 51195ab
wip
Mr-Leshiy af8bbdd
wip
Mr-Leshiy a600ae1
fix
Mr-Leshiy 09901d3
wip
Mr-Leshiy 7aacebb
remove coset
Mr-Leshiy bb996cd
fix clippy
Mr-Leshiy 6e009c9
wip
Mr-Leshiy 120273b
fix spelling
Mr-Leshiy b93c694
wip
Mr-Leshiy 34fa732
wip
Mr-Leshiy 379cc59
wip
Mr-Leshiy 11e99c4
wip
Mr-Leshiy a0c24bf
fix comment
Mr-Leshiy 8dbb315
wip
Mr-Leshiy c258171
Merge branch 'feat/new-cat-signed-doc' into feat/decoder
Mr-Leshiy d83460f
add Collaborators type
Mr-Leshiy 857410a
wip
Mr-Leshiy 702561f
Merge branch 'feat/new-cat-signed-doc' into feat/decoder
Mr-Leshiy 88e2c63
wip
Mr-Leshiy ee97869
fix clippy
Mr-Leshiy 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
//! Catalyst Signed Document `collabs` field type definition. | ||
|
||
use std::ops::Deref; | ||
|
||
/// 'collabs' field type definition, which is a JSON path string | ||
#[derive(Clone, Debug, PartialEq)] | ||
pub struct Collaborators(Vec<String>); | ||
|
||
impl Deref for Collaborators { | ||
type Target = Vec<String>; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
&self.0 | ||
} | ||
} | ||
|
||
impl minicbor::Encode<()> for Collaborators { | ||
fn encode<W: minicbor::encode::Write>( | ||
&self, e: &mut minicbor::Encoder<W>, _ctx: &mut (), | ||
) -> Result<(), minicbor::encode::Error<W::Error>> { | ||
if !self.0.is_empty() { | ||
e.array( | ||
self.0 | ||
.len() | ||
.try_into() | ||
.map_err(minicbor::encode::Error::message)?, | ||
)?; | ||
for c in &self.0 { | ||
e.str(c)?; | ||
} | ||
} | ||
Ok(()) | ||
} | ||
} | ||
|
||
impl minicbor::Decode<'_, ()> for Collaborators { | ||
fn decode( | ||
d: &mut minicbor::Decoder<'_>, _ctx: &mut (), | ||
) -> Result<Self, minicbor::decode::Error> { | ||
let Some(items) = d.array()? else { | ||
return Err(minicbor::decode::Error::message( | ||
"Must a definite size array", | ||
)); | ||
}; | ||
let collabs = (0..items) | ||
.map(|_| Ok(d.str()?.to_string())) | ||
.collect::<Result<_, _>>()?; | ||
Ok(Self(collabs)) | ||
} | ||
} | ||
|
||
impl<'de> serde::Deserialize<'de> for Collaborators { | ||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> | ||
where D: serde::Deserializer<'de> { | ||
Ok(Self(Vec::<String>::deserialize(deserializer)?)) | ||
} | ||
} |
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.
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.