-
Notifications
You must be signed in to change notification settings - Fork 11.3k
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
[fastx client] Create a clean object reading interface (Part 4) #392
Conversation
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.
Approve with some suggestions.
fastpay_core/src/client.rs
Outdated
@@ -48,6 +49,30 @@ pub struct ClientState<AuthorityAPI> { | |||
store: ClientStore, | |||
} | |||
|
|||
pub enum ObjectRead { |
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.
ObjectReadResult
is probably a better name?
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 Rust lingo Result usually suggests its a Result< something, something Error>, so I would stay away from that word.
fastpay_core/src/client.rs
Outdated
impl ObjectRead { | ||
pub fn object(&self) -> Result<&Object, FastPayError> { | ||
match &self { | ||
ObjectRead::Deleted(oref) => Err(FastPayError::ObjectDeleted { object_ref: *oref }), |
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.
You can use Self
whenever ObjectRead
is needed, so that if we ever rename the struct you don't need to change them.
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.
Great suggestion! Then we can work out what to call it.
a50c41e
to
2a7572a
Compare
1466dad
to
13c3c9d
Compare
ObjectRead
structure with a clearExists
,NotExists
,Deleted
set of enums.get_object_info
on client to just take object ID and return the last version as anObjectRead
get_object_info
semanticsget_object_info
logic