#flatpak

flatpak

Flatpak library for Rust

49 releases (16 breaking)

0.18.1 Aug 17, 2022
0.18.0 Jun 28, 2022
0.17.2 Jun 27, 2022
0.12.1 Mar 18, 2022

#3 in #lib

Download history 29/week @ 2022-08-12 16/week @ 2022-08-19 50/week @ 2022-08-26 2/week @ 2022-09-02 150/week @ 2022-09-09 1/week @ 2022-09-16 7/week @ 2022-09-23 83/week @ 2022-09-30 13/week @ 2022-10-07 58/week @ 2022-10-14 29/week @ 2022-10-21 6/week @ 2022-10-28 63/week @ 2022-11-04 8/week @ 2022-11-11 67/week @ 2022-11-18 5/week @ 2022-11-25

144 downloads per month
Used in anda

MIT license

125KB
2.5K SLoC

flatpak-rs

Flatpak library for Rust.

Tests status Code formatting Documentation dependency status Crates.io version License file

This library offers functions to parse and dump flatpak application, module or source manifests. The goal of the library is to be compliant with what flatpak-builder supports.

See the API documentation for this library.

Installation

Add the library to your Cargo.toml:

flatpak = "0"

Experimental TOML support is available via the toml feature:

flatpak = { version = "0", features = ["toml"] }

Note that this library is aliased as both flatpak and flatpak-rs on crates.io.

Usage

All three denominations of Flatpak manifests can be parsed using this library, using the FlatpakApplication, FlatpakModule and FlatpakSource structs.

Parse from a string

use flatpak_rs::application::FlatpakApplication;
use flatpak_rs::format::FlatpakManifestFormat;

let manifest = r###"
    app-id: net.louib.flatpak-rs
    runtime: org.gnome.Platform
    runtime-version: "3.36"
    sdk: org.gnome.Sdk
    command: flatpak-rs
    tags: ["nightly"]
    modules:
      -
        name: "flatpak-rs"
        buildsystem: simple
        cleanup: [ "*" ]
        config-opts: []
        sources:
          -
            type: git
            url: https://github.com/louib/flatpak-rs.git
            branch: master
      -
        "shared-modules/linux-audio/lv2.json"
"###;

let application = FlatpakApplication::parse(FlatpakManifestFormat::YAML, manifest).unwrap();

assert_eq!(&application.app_id, "net.louib.flatpak-rs");
assert_eq!(application.modules.len(), 2 as usize);

println!("Parsed application manifest for {}.", &application.app_id);

Parse from a file

use std::env;

use flatpak_rs::application::FlatpakApplication;

fn main() {
    let args: Vec<String> = env::args().collect();
    if args.len() < 2 {
        eprintln!("Please provide a flatpak application manifest to parse.");
        return;
    }
    let manifest_path = &args[1];

    let application = FlatpakApplication::load_from_file(manifest_path.clone()).unwrap();
    println!("Parsed application manifest for {}.", &application.get_id());
}

License

MIT

Dependencies

~2.7–4MB
~99K SLoC