-
Notifications
You must be signed in to change notification settings - Fork 244
Refactor RawFeltVec
#3849
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
base: spr/master/b701265d
Are you sure you want to change the base?
Refactor RawFeltVec
#3849
Conversation
f3341f3 to
975c55c
Compare
5be308b to
2fb1cab
Compare
2fb1cab to
5f1378b
Compare
975c55c to
b529f57
Compare
5f1378b to
61e2887
Compare
b529f57 to
a5347c6
Compare
61e2887 to
b6dbc2c
Compare
275f396 to
12fa2fe
Compare
b6dbc2c to
7a5f8b2
Compare
| /// use this wrapper to NOT add extra length felt | ||
| /// useful e.g. when you need to pass an already serialized value | ||
| #[derive(Debug)] | ||
| pub struct NoLengthFeltVec<T>(pub Vec<T>) |
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.
Maybe we could name it SerializedValue? As this i think is only usefull if value is serialized
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.
Renaming
12fa2fe to
f955261
Compare
7a5f8b2 to
69854b2
Compare
69854b2 to
45efdc4
Compare
| /// | ||
| /// Use this to omit adding extra felt for the length of the vector during serialization. | ||
| #[derive(Debug)] | ||
| pub struct SerializedValue<T>(pub Vec<T>) |
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.
I would also drop generic. Only valid representation i would say is pub struct SerializedValue(pub Vec<Felt>)
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.
There's one use case where we want to write serialized array of ResourceBounds structs into memory in serialized format and we do it as so
&SerializedValue::new(resource_bounds).serialize_to_vec(),We can change serialized value to be a Vec<Felt> but we would either have to provide an constructor that allows creating it from other values that implement serialize (we would have to do the serialization at construction time though) or change the usage to something along the lines of
&resource_bounds
.iter()
.flat_map(conversions::serde::serialize::SerializeToFeltVec::serialize_to_vec)
.collect::<Vec<_>>(),which kind of duplicates the logic.
| } | ||
| } | ||
|
|
||
| impl CairoDeserialize for SerializedValue<Felt> { |
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.
Is this needed?
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, we need it to .read() the already serialized data that oracle returns.
commit-id:30d7f8cd
45efdc4 to
a2eeb0b
Compare
f955261 to
74c94e0
Compare
Stack:
RawFeltVec#3849 ⬅