alpm_types::relation

Enum SonameV1

Source
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 the name 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 the name of a shared object file, its soname (which does not expose a specific version) and its architecture (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 the name of a shared object file, the version from its soname and its architecture (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

Source

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:

§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()?
    }
);
Source

pub fn parser(input: &mut &str) -> ModalResult<Self>

Parses a SonameV1 from a string slice.

Source

fn parse_shared_object_name(input: &mut &str) -> ModalResult<SharedObjectName>

Parses the shared object name until the version delimiter =.

Source

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.

Source

fn parse_architecture_delimiter(input: &mut &str) -> ModalResult<()>

Parses the architecture delimiter -.

Source

fn parse_architecture(input: &mut &str) -> ModalResult<ElfArchitectureFormat>

Parses the architecture.

Trait Implementations§

Source§

impl Clone for SonameV1

Source§

fn clone(&self) -> SonameV1

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SonameV1

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for SonameV1

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl FromStr for SonameV1

Source§

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()?),
);
Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

impl PartialEq for SonameV1

Source§

fn eq(&self, other: &SonameV1) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for SonameV1

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for SonameV1

Source§

impl StructuralPartialEq for SonameV1

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T