Sha256: 04b41bb9efa473a661785003c3ffcc250284fe25e6113a4c2582f5d74f39d046

Contents?: true

Size: 1.4 KB

Versions: 38

Compression:

Stored size: 1.4 KB

Contents

/// Represents the kind of search path.
#[derive(Debug, PartialEq, Eq)]
pub enum SearchPathKind {
    Native,
    Framework,
}

/// Represents a library taht can be linked with Cargo.
#[derive(Debug, PartialEq, Eq)]
pub struct SearchPath {
    pub kind: SearchPathKind,
    pub name: String,
}

impl From<&str> for SearchPathKind {
    fn from(s: &str) -> Self {
        match s {
            "framework" => SearchPathKind::Framework,
            "native" => SearchPathKind::Native,
            _ => panic!("Unknown lib kind: {}", s),
        }
    }
}

impl From<&str> for SearchPath {
    fn from(s: &str) -> Self {
        let parts: Vec<_> = s.split('=').collect();

        match parts.len() {
            1 => (SearchPathKind::Native, parts[0]).into(),
            2 => (parts[0], parts[1]).into(),
            _ => panic!("Invalid library specification: {}", s),
        }
    }
}

impl<K, T> From<(K, T)> for SearchPath
where
    K: Into<SearchPathKind>,
    T: Into<String>,
{
    fn from((kind, name): (K, T)) -> Self {
        Self {
            kind: kind.into(),
            name: name.into(),
        }
    }
}

impl std::fmt::Display for SearchPath {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self.kind {
            SearchPathKind::Framework => write!(f, "framework={}", self.name),
            SearchPathKind::Native => write!(f, "native={}", self.name),
        }
    }
}

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
wasmtime-14.0.3 ./ext/cargo-vendor/rb-sys-build-0.9.82/src/rb_config/search_path.rs
wasmtime-14.0.1 ./ext/cargo-vendor/rb-sys-build-0.9.82/src/rb_config/search_path.rs
wasmtime-14.0.0 ./ext/cargo-vendor/rb-sys-build-0.9.82/src/rb_config/search_path.rs
wasmtime-13.0.0 ./ext/cargo-vendor/rb-sys-build-0.9.81/src/rb_config/search_path.rs
wasmtime-12.0.1 ./ext/cargo-vendor/rb-sys-build-0.9.81/src/rb_config/search_path.rs
wasmtime-12.0.0 ./ext/cargo-vendor/rb-sys-build-0.9.81/src/rb_config/search_path.rs
wasmtime-11.0.0 ./ext/cargo-vendor/rb-sys-build-0.9.81/src/rb_config/search_path.rs
wasmtime-10.0.1 ./ext/cargo-vendor/rb-sys-build-0.9.81/src/rb_config/search_path.rs
wasmtime-10.0.0 ./ext/cargo-vendor/rb-sys-build-0.9.81/src/rb_config/search_path.rs
wasmtime-9.0.4 ./ext/cargo-vendor/rb-sys-build-0.9.81/src/rb_config/search_path.rs
wasmtime-9.0.1 ./ext/cargo-vendor/rb-sys-build-0.9.78/src/rb_config/search_path.rs
wasmtime-8.0.0 ./ext/cargo-vendor/rb-sys-build-0.9.72/src/rb_config/search_path.rs
wasmtime-7.0.0 ./ext/cargo-vendor/rb-sys-build-0.9.70/src/rb_config/search_path.rs
wasmtime-6.0.1 ./ext/cargo-vendor/rb-sys-build-0.9.65/src/rb_config/search_path.rs
wasmtime-6.0.0 ./ext/cargo-vendor/rb-sys-build-0.9.65/src/rb_config/search_path.rs
wasmtime-5.0.0 ./ext/cargo-vendor/rb-sys-build-0.9.57/src/rb_config/search_path.rs
wasmtime-0.4.1 ./ext/cargo-vendor/rb-sys-build-0.9.53/src/rb_config/search_path.rs
wasmtime-0.4.0 ./ext/cargo-vendor/rb-sys-build-0.9.52/src/rb_config/search_path.rs