Glib-oriented client for Gemini protocol https://crates.io/crates/ggemini
Find a file
2025-01-18 02:18:56 +02:00
.github/workflows add libglib2.0-dev dependency 2025-01-13 21:30:19 +02:00
src store MIME value in lowercase presentation 2025-01-18 02:18:56 +02:00
tests update gemini test conditions 2025-01-14 00:47:53 +02:00
.gitignore init crate 2024-10-18 21:34:49 +03:00
Cargo.toml implement Titan protocol features 2025-01-13 21:22:03 +02:00
LICENSE Initial commit 2024-10-18 21:24:15 +03:00
README.md implement Request constructors, remove build methods 2025-01-13 23:14:54 +02:00

ggemini

Build Documentation crates.io

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 dependent of glib and/or gio (2.66+) bindings.

Requirements

Debian
sudo apt install libglib2.0-dev
Fedora
sudo dnf install glib2-devel

Install

cargo add ggemini

Usage

Example

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<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
}
  • to send requests using Titan protocol, see titan_request_async implementation

Other crates