pub enum SonameV1 {
Basic(SharedObjectName),
Unversioned {
name: SharedObjectName,
soname: SharedObjectName,
architecture: ElfArchitectureFormat,
},
Explicit {
name: SharedObjectName,
version: PackageVersion,
architecture: ElfArchitectureFormat,
},
}
Expand description
Representation of soname data of a shared object based on the alpm-sonamev1 specification.
Soname data may be used as alpm-package-relation of type provision and run-time dependency. This type distinguishes between three forms: basic, unversioned and explicit.
SonameV1::Basic
is used when only thename
of a shared object file is used. This form can be used in files that may contain static data about package sources (e.g. PKGBUILD or SRCINFO files).SonameV1::Unversioned
is used when thename
of a shared object file, its soname (which does not expose a specific version) and itsarchitecture
(derived from the ELF class of the file) are used. This form can be used in files that may contain dynamic data derived from a specific package build environment (i.e. PKGINFO). It is discouraged to use this form in files that contain static data about package sources (e.g. PKGBUILD or SRCINFO files).SonameV1::Explicit
is used when thename
of a shared object file, theversion
from its soname and itsarchitecture
(derived from the ELF class of the file) are used. This form can be used in files that may contain dynamic data derived from a specific package build environment (i.e. PKGINFO). It is discouraged to use this form in files that contain static data about package sources (e.g. PKGBUILD or SRCINFO files).
§Warning
This type is deprecated and SonameV2
should be preferred instead!
Due to the loose nature of the alpm-sonamev1 specification, the basic form overlaps with the
specification of Name
and the explicit form overlaps with that of PackageRelation
.
§Examples
use alpm_types::{ElfArchitectureFormat, SonameV1};
let basic_soname = SonameV1::Basic("example.so".parse()?);
let unversioned_soname = SonameV1::Unversioned {
name: "example.so".parse()?,
soname: "example.so".parse()?,
architecture: ElfArchitectureFormat::Bit64,
};
let explicit_soname = SonameV1::Explicit {
name: "example.so".parse()?,
version: "1.0.0".parse()?,
architecture: ElfArchitectureFormat::Bit64,
};
Variants§
Basic(SharedObjectName)
Basic representation of a shared object file.
Tracks the name
of a shared object file.
This form is used when referring to shared object files without their soname data.
§Examples
use std::str::FromStr;
use alpm_types::SonameV1;
let soname = SonameV1::from_str("example.so")?;
assert_eq!(soname, SonameV1::Basic("example.so".parse()?));
Unversioned
Unversioned representation of an ELF file’s soname data.
Tracks the name
of a shared object file, its soname instead of a version and its
architecture
. This form is used if the soname data of a shared object does not
expose a version.
§Examples
use std::str::FromStr;
use alpm_types::{ElfArchitectureFormat, SonameV1};
let soname = SonameV1::from_str("example.so=example.so-64")?;
assert_eq!(
soname,
SonameV1::Unversioned {
name: "example.so".parse()?,
soname: "example.so".parse()?,
architecture: ElfArchitectureFormat::Bit64,
}
);
Fields
name: SharedObjectName
The least specific name of the shared object file.
soname: SharedObjectName
The value of the shared object’s SONAME field in its dynamic section.
architecture: ElfArchitectureFormat
The ELF architecture format of the shared object file.
Explicit
Explicit representation of an ELF file’s soname data.
Tracks the name
of a shared object file, the version
of its soname and its
architecture
. This form is used if the soname data of a shared object exposes a
specific version.
§Examples
use std::str::FromStr;
use alpm_types::{ElfArchitectureFormat, SonameV1};
let soname = SonameV1::from_str("example.so=1.0.0-64")?;
assert_eq!(
soname,
SonameV1::Explicit {
name: "example.so".parse()?,
version: "1.0.0".parse()?,
architecture: ElfArchitectureFormat::Bit64,
}
);
Fields
name: SharedObjectName
The least specific name of the shared object file.
version: PackageVersion
The version of the shared object file (as exposed in its soname data).
architecture: ElfArchitectureFormat
The ELF architecture format of the shared object file.
Implementations§
Source§impl SonameV1
impl SonameV1
Sourcepub fn new(
name: SharedObjectName,
version_or_soname: Option<VersionOrSoname>,
architecture: Option<ElfArchitectureFormat>,
) -> Result<Self, Error>
pub fn new( name: SharedObjectName, version_or_soname: Option<VersionOrSoname>, architecture: Option<ElfArchitectureFormat>, ) -> Result<Self, Error>
Creates a new SonameV1
.
Depending on input, this function returns different variants of SonameV1
:
SonameV1::Basic
, if bothversion_or_soname
andarchitecture
areNone
SonameV1::Unversioned
, ifversion_or_soname
isVersionOrSoname::Soname
andarchitecture
isSome
SonameV1::Explicit
, ifversion_or_soname
isVersionOrSoname::Version
andarchitecture
isSome
§Examples
use alpm_types::{ElfArchitectureFormat, SonameV1};
let basic_soname = SonameV1::new("example.so".parse()?, None, None)?;
assert_eq!(basic_soname, SonameV1::Basic("example.so".parse()?));
let unversioned_soname = SonameV1::new(
"example.so".parse()?,
Some("example.so".parse()?),
Some(ElfArchitectureFormat::Bit64),
)?;
assert_eq!(
unversioned_soname,
SonameV1::Unversioned {
name: "example.so".parse()?,
soname: "example.so".parse()?,
architecture: "64".parse()?
}
);
let explicit_soname = SonameV1::new(
"example.so".parse()?,
Some("1.0.0".parse()?),
Some(ElfArchitectureFormat::Bit64),
)?;
assert_eq!(
explicit_soname,
SonameV1::Explicit {
name: "example.so".parse()?,
version: "1.0.0".parse()?,
architecture: "64".parse()?
}
);
Parses the shared object name until the version delimiter =
.
Sourcefn parse_version_delimiter(input: &mut &str) -> ModalResult<()>
fn parse_version_delimiter(input: &mut &str) -> ModalResult<()>
Parses the version delimiter =
.
This function discards the result for only checking if the version delimiter is present.
Sourcefn parse_architecture_delimiter(input: &mut &str) -> ModalResult<()>
fn parse_architecture_delimiter(input: &mut &str) -> ModalResult<()>
Parses the architecture delimiter -
.
Sourcefn parse_architecture(input: &mut &str) -> ModalResult<ElfArchitectureFormat>
fn parse_architecture(input: &mut &str) -> ModalResult<ElfArchitectureFormat>
Parses the architecture.
Trait Implementations§
Source§impl FromStr for SonameV1
impl FromStr for SonameV1
Source§fn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
Parses a SonameV1
from a string slice.
The string slice must be in the format name[=version-architecture]
.
§Errors
Returns an error if a SonameV1
can not be parsed from input.
§Examples
use std::str::FromStr;
use alpm_types::{ElfArchitectureFormat, SonameV1};
assert_eq!(
SonameV1::from_str("example.so=1.0.0-64")?,
SonameV1::Explicit {
name: "example.so".parse()?,
version: "1.0.0".parse()?,
architecture: ElfArchitectureFormat::Bit64,
},
);
assert_eq!(
SonameV1::from_str("example.so=example.so-64")?,
SonameV1::Unversioned {
name: "example.so".parse()?,
soname: "example.so".parse()?,
architecture: ElfArchitectureFormat::Bit64,
},
);
assert_eq!(
SonameV1::from_str("example.so")?,
SonameV1::Basic("example.so".parse()?),
);