-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Update readme #26
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: main
Are you sure you want to change the base?
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.
I didn't repeat comments all over the place.
We should probably consider splitting README.md and the crate entry docs.
Also we should add a section on compatibility with the cloudevents-sdk
crate.
Right now the code in the examples feels very "go-like" and I added some comments on how to make them more "rusty".
if result.is_err() { | ||
// ... | ||
} |
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.
This method of error handling is strongly discouraged in Rust, since you need to extract the Err or Ok type anyways.
This type of error handling is "very go-like" and for Rust I'd recommend using the ?
operator or .expect("Reason")
in examples instead as it is more concise and more "rusty".
Then call the `ping` function to check whether the instance is reachable. If it is not, the function will return an error: | ||
|
||
```rust | ||
let result = client.ping(); |
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.
As I wrote in the issue, this file will be run as part of tests with each rust codeblock being its own test right now (this is also why QA is failing).
We either need to separate the two (which would probably be better IMO) and move the "real" examples into the lib.rs file where they can be checked and lines of code can be hidden or make the examples valid here (so e.g. by setting up a testcontainer DB).
let client = Client::new(base_url, api_token); | ||
``` | ||
|
||
Then call the `ping` function to check whether the instance is reachable. If it is not, the function will return an error: |
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.
ping
-> [client::Client::ping
] for RustDoc (so it links). This would also not be necessary when separating the two docs parts.
|
||
*Note that `Ping` does not require authentication, so the call may succeed even if the API token is invalid.* | ||
|
||
If you want to verify the API token, call `verify_api_token`. If the token is invalid, the function will return an error: |
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.
same as with ping
let result = client.verify_api_token(); | ||
if result.is_err() { | ||
// ... | ||
} |
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.
Has to be valid Rust example right now - see above
"author": "Arthur C. Clarke", | ||
"isbn": "978-0756906788", | ||
})) | ||
.build() |
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.
missing ;
match result { | ||
Ok(written_events) => // ... | ||
Err(err) => // ... | ||
} |
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.
also here I recommend doing ?
ObserveEventsRequestOptions { | ||
recursive: true, | ||
..Default::default(), | ||
} |
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.
This Options do not yet implement Default
(#27 tracks implementing it).
No description provided.