libalternatives-rs 0.1.0

Rust bindings for libalternatives library from OpenSUSE
#![allow(non_camel_case_types)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]

use crate::Alternative;

include!(concat!(env!("OUT_DIR"), "/bindings.rs"));

impl AlternativeLink {
    /// Converts `ffi::AlternativeLink` to `crate::Alternative`
    pub fn to_alternative(self) -> Alternative {
        unsafe {
            use std::ffi::CStr;

            Alternative {
                priority: self.priority,
                r#type: super::LinkType::try_from(self.type_).unwrap(),
                target: CStr::from_ptr(self.target).to_str().unwrap().to_string(),
                options: super::LinkOptions::try_from(self.options as i32).unwrap(),
            }
        }
    }
}