diff --git a/README.md b/README.md index 5eb2487..60746a0 100644 --- a/README.md +++ b/README.md @@ -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| 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 \ No newline at end of file