# ggemini

[](https://docs.rs/ggemini)
[](https://crates.io/crates/ggemini)
Glib/Gio-oriented network API for [Gemini protocol](https://geminiprotocol.net/)
> [!IMPORTANT]
> Project in development!
>
GGemini (or G-Gemini) library written as the client extension for [Yoda](https://github.com/YGGverse/Yoda), it also could be useful for other GTK-based applications dependent of [glib](https://crates.io/crates/glib) and/or [gio](https://crates.io/crates/gio) (`2.66+`) bindings.
## Requirements
Debian
sudo apt install libglib2.0-dev
Fedora
sudo dnf install glib2-devel
## Install
```
cargo add ggemini
```
## Usage
* [Documentation](https://docs.rs/ggemini/latest/ggemini/)
### Example
``` rust
use gio::*;
use glib::*;
use ggemini::client::{
connection::{
Request, Response,
request::Gemini,
response::meta::{Mime, Status}
},
Client, Error,
};
fn main() -> ExitCode {
Client::new().request_async(
Request::gemini(
Uri::parse(REQUEST, UriFlags::NONE).unwrap(),
),
Priority::DEFAULT,
Cancellable::new(),
None, // optional `GTlsCertificate`
|result: Result| match result {
Ok(response) => {
// route by status code
match response.meta.status {
// is code 20, handle `GIOStream` by content type
Status::Success => match response.meta.mime.unwrap().value.as_str() {
// is gemtext, see ggemtext crate to parse
"text/gemini" => todo!(),
// other types
_ => todo!(),
},
_ => todo!(),
}
}
Err(e) => todo!("{e}"),
},
);
ExitCode::SUCCESS
}
```
* to send requests using Titan protocol, see `titan_request_async` implementation
## Other crates
* [ggemtext](https://github.com/YGGverse/ggemtext) - Glib-oriented Gemtext API