Glib-oriented client for Gemini protocol https://crates.io/crates/ggemini
Find a file
2024-12-20 10:22:35 +02:00
.github/workflows rename workflow 2024-12-20 10:22:35 +02:00
src remove extra line 2024-12-14 06:23:10 +02:00
tests rename integration file 2024-12-01 11:51:10 +02:00
.gitignore init crate 2024-10-18 21:34:49 +03:00
Cargo.toml update version 2024-12-14 10:29:46 +02:00
LICENSE Initial commit 2024-10-18 21:24:15 +03:00
README.md update example with new api version 2024-12-14 06:28:48 +02:00

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