#binding #bindings

clingo

Rust idiomatic bindings to the clingo library

11 unstable releases

0.7.2 Aug 27, 2021
0.6.0 Jan 3, 2020
0.5.0 Nov 4, 2019
0.4.3 Jul 10, 2019
0.1.0 May 4, 2017

#124 in Algorithms

Download history 33/week @ 2022-06-09 25/week @ 2022-06-16 23/week @ 2022-06-23 19/week @ 2022-06-30 35/week @ 2022-07-07 29/week @ 2022-07-14 71/week @ 2022-07-21 37/week @ 2022-07-28 56/week @ 2022-08-04 27/week @ 2022-08-11 27/week @ 2022-08-18 44/week @ 2022-08-25 32/week @ 2022-09-01 57/week @ 2022-09-08 16/week @ 2022-09-15 26/week @ 2022-09-22

141 downloads per month

MIT license

400KB
8K SLoC

clingo-rs Build Status Latest Version Rust Documentation

Rust bindings to the clingo library. Clingo version 5.5.0.

Requirements

  • a c++14 conforming compiler
    • at least gcc version 4.9
    • clang version 3.1 (using either libstdc++ provided by gcc 4.9 or libc++)

Per default the crate uses the clingo library via dynamic linking. It is assumed that a clingo dynamic library is installed on the system. You have to set the environment variable CLINGO_LIBRARY_PATH. For example:

export CLINGO_LIBRARY_PATH=/scratch/miniconda3/envs/test/lib

Examples

cargo run --example=ast 0
cargo run --example=backend 0
cargo run --example=configuration
cargo run --example=control 0
cargo run --example=model 0
cargo run --example=propagator 0
cargo run --example=solve-async 0
cargo run --example=statistics 0
cargo run --example=symbol 0
cargo run --example=symbolic-atoms 0
cargo run --example=theory-atoms 0
cargo run --example=inject-terms 0
cargo run --example=version

Features

Using derive macro

The crate provides a derive macro to help easing the use of rust data types as facts.

In your Cargo.toml add:

[dependencies]
clingo = { version = "0.7.2", features = ["derive"] }

In your source write:

use clingo::ToSymbol;
use clingo::ClingoError;
use clingo::FactBase;

#[derive(ToSymbol)]
struct MyPoint {
    x: i32,
    y: i32,
}

let p = MyPoint{ x:4, y:2 };
let fb = FactBase::new();
fb.insert(p);

The macro performs a conversion to snake case. This means the corresponing fact for MyPoint{x:4,y:2} is my_point(4,2).

Using static-linking

You can use the clingo library via static linking.

The recommended way to use the optional static linking support is as follows.

[dependencies]
clingo = { version = "0.7.2", features = ["static-linking"] }

Contribution

How to make a contribution to clingo-rs?

Any contribution intentionally submitted for inclusion in the work by you, shall be licensed under the terms of the MIT license without any additional terms or conditions.

Dependencies

~7.5MB
~156K SLoC