Skip to content

Commit

Permalink
add usage example
Browse files Browse the repository at this point in the history
  • Loading branch information
yggverse committed Dec 1, 2024
1 parent d313f90 commit a77e4ab
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,45 @@ cargo add ggemini

* [Documentation](https://docs.rs/ggemini/latest/ggemini/)

### Example

``` rust
use gtk::gio::*;
use gtk::glib::*;

use ggemini::client::{
connection::{
response::meta::{Mime, Status},
Response,
},
Client, Error,
};

fn main() -> ExitCode {
Client::new().request_async(
Uri::parse("gemini://geminiprotocol.net/", UriFlags::NONE).unwrap(),
Priority::DEFAULT,
Cancellable::new(),
None, // optional `GTlsCertificate`
|result: Result<Response, Error>| match result {
Ok(response) => {
match response.meta.status {
// route by status code
Status::Success => match response.meta.mime {
// handle `GIOStream` by content type
Some(Mime::TextGemini) => todo!(),
_ => todo!(),
},
_ => todo!(),
}
}
Err(e) => todo!("{e}"),
},
);
ExitCode::SUCCESS
}
```

## See also

* [ggemtext](https://github.com/YGGverse/ggemtext) - Glib-oriented Gemtext API

0 comments on commit a77e4ab

Please sign in to comment.