#gemini #gtk #gio #client #gemini-protocol #networking

ggemini

Glib/Gio-oriented network API for Gemini protocol

12 breaking releases

0.13.0 Dec 14, 2024
0.11.0 Dec 1, 2024
0.10.0 Nov 16, 2024

#1016 in Network programming

Download history 66/week @ 2024-10-12 402/week @ 2024-10-19 596/week @ 2024-10-26 212/week @ 2024-11-02 14/week @ 2024-11-09 120/week @ 2024-11-16 17/week @ 2024-11-23 180/week @ 2024-11-30 172/week @ 2024-12-07 246/week @ 2024-12-14 4/week @ 2024-12-21 1/week @ 2024-12-28

434 downloads per month
Used in yoda

MIT license

41KB
883 lines

ggemini

Glib/Gio-oriented network API for Gemini protocol

[!IMPORTANT] Project in development!

GGemini (or G-Gemini) library written as the client extension for Yoda, it also could be useful for other GTK-based applications with glib and gio (2.66+) dependency.

Install

cargo add ggemini

Usage

Example

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) => {
                // 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
}

See also

Dependencies

~7–15MB
~216K SLoC