GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - DUpdateSystem/libversion-sys: Rust bindings for libversion

BranchesTags
Open more actions menu

Latest commit

 

History

16 Commits
16 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
generated/libversion
generated/libversion
 
 
libversion @ 0c2c247
libversion @ 0c2c247
 
 
scripts
scripts
 
 
src
src
 
 
.gitignore
.gitignore
 
 
.gitmodules
.gitmodules
 
 
Cargo.lock
Cargo.lock
 
 
Cargo.toml
Cargo.toml
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
build.rs
build.rs
 
 
wrapper.h
wrapper.h
 
 

Repository files navigation

libversion-sys

Crates.io docs.rs License: MIT

Rust FFI bindings to libversion, an advanced version string comparison library.

By default the crate vendors the C source and builds it directly, so no system-level installation of libversion is required. If you prefer linking an installed system copy, disable default features and make sure pkg-config can find libversion.

Usage

Add to Cargo.toml:

[dependencies]
libversion-sys = "0.2"

Use the default vendored build:

[dependencies]
libversion-sys = "0.2"

Or link a system-installed libversion:

[dependencies]
libversion-sys = { version = "0.2", default-features = false }

Safe API

use std::cmp::Ordering;
use libversion_sys::{compare, compare_with_flags, VERSIONFLAG_P_IS_PATCH};

assert_eq!(compare("1.0", "1.1"), Ordering::Less);
assert_eq!(compare("1.0", "1.0.0"), Ordering::Equal);
assert_eq!(compare("1.0alpha1", "1.0"), Ordering::Less);

// "p" as patch (post-release) instead of pre-release
assert_eq!(
    compare_with_flags("1.0p1", "1.0", VERSIONFLAG_P_IS_PATCH, 0),
    Ordering::Greater,
);

Raw FFI

use std::ffi::CString;
use libversion_sys::ffi;

let v1 = CString::new("1.0").unwrap();
let v2 = CString::new("2.0").unwrap();
let result = unsafe { ffi::version_compare2(v1.as_ptr(), v2.as_ptr()) };
assert_eq!(result, -1);

Version metadata

assert!(libversion_sys::version_atleast(3, 0, 0));
assert!(!libversion_sys::version_string().is_empty());

Flags

Flag Description
VERSIONFLAG_P_IS_PATCH Treat p as patch (post-release) instead of pre-release
VERSIONFLAG_ANY_IS_PATCH Treat any letter sequence as post-release
VERSIONFLAG_LOWER_BOUND Derive lowest possible version with the given prefix
VERSIONFLAG_UPPER_BOUND Derive highest possible version with the given prefix

Build requirements

  • Rust (stable)
  • C compiler (gcc/clang) for the default vendored build
  • libclang (for bindgen)
  • pkg-config and a system libversion installation when building with default-features = false

On Ubuntu/Debian:

sudo apt-get install libclang-dev

For system linking:

sudo apt-get install pkg-config libversion-dev

cmake is only needed by maintainers when regenerating generated/libversion/config.h and generated/libversion/export.h after updating the vendored libversion source.

License

MIT -- see LICENSE.

The bundled libversion is also MIT licensed.

About

Rust bindings for libversion

crates.io/crates/libversion-sys

Resources

Readme
MIT license

Code of conduct

Code of conduct

Contributing

Contributing
Activity
Custom properties

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.