Skip to content

Latest commit

 

History

History
85 lines (68 loc) · 2.22 KB

README.md

File metadata and controls

85 lines (68 loc) · 2.22 KB

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( // or `Request::titan`
            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 {
                    // code 20, handle `GIOStream` by content type
                    Status::Success => match response.meta.mime.unwrap().value.as_str() {
                        // gemtext, see ggemtext crate to parse
                        "text/gemini" => todo!(),
                        // other content types
                        _ => todo!(),
                    },
                    _ => todo!(),
                }
            }
            Err(_) => todo!(),
        },
    );
    ExitCode::SUCCESS
}

Other crates