Struct SonameV2

Source
pub struct SonameV2 {
    pub prefix: SharedLibraryPrefix,
    pub soname: Soname,
}
Expand description

Representation of soname data of a shared object based on the alpm-sonamev2 specification.

Soname data may be used as alpm-package-relation of type provision or run-time dependency in PackageInfoV1 and PackageInfoV2. The data consists of the arbitrarily defined prefix, which denotes the use name of a specific library directory, and the soname, which refers to the value of either the SONAME or a NEEDED field in the dynamic section of an ELF file.

§Examples

This example assumpes that lib is used as the prefix for the library directory /usr/lib and the following files are contained in it:

/usr/lib/libexample.so -> libexample.so.1
/usr/lib/libexample.so.1 -> libexample.so.1.0.0
/usr/lib/libexample.so.1.0.0

The above file /usr/lib/libexample.so.1.0.0 represents an ELF file, that exposes libexample.so.1 as value of the SONAME field in its dynamic section. This data can be represented as follows, using SonameV2:

use alpm_types::{Soname, SonameV2};

let soname_data = SonameV2 {
    prefix: "lib".parse()?,
    soname: Soname {
        name: "libexample.so".parse()?,
        version: Some("1".parse()?),
    },
};
assert_eq!(soname_data.to_string(), "lib:libexample.so.1");

Fields§

§prefix: SharedLibraryPrefix

The directory prefix of the shared object file.

§soname: Soname

The soname of a shared object file.

Implementations§

Source§

impl SonameV2

Source

pub fn new(prefix: SharedLibraryPrefix, soname: Soname) -> Self

Creates a new SonameV2.

§Examples
use alpm_types::SonameV2;

SonameV2::new("lib".parse()?, "libexample.so.1".parse()?);
Source

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

Recognizes a SonameV2 in a string slice.

The passed data must be in the format <prefix>:<soname>. (e.g. lib:libexample.so.1)

See Soname::parser for details on the format of <soname>.

§Errors

Returns an error if no SonameV2 can be created from input.

Trait Implementations§

Source§

impl Clone for SonameV2

Source§

fn clone(&self) -> SonameV2

Returns a duplicate 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 SonameV2

Source§

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

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

impl<'de> Deserialize<'de> for SonameV2

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for SonameV2

Source§

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

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

impl FromStr for SonameV2

Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a SonameV2 from a string slice.

The string slice must be in the format <prefix>:<soname>.

§Errors

Returns an error if a SonameV2 can not be parsed from input.

§Examples
use std::str::FromStr;

use alpm_types::{Soname, SonameV2};

assert_eq!(
    SonameV2::from_str("lib:libexample.so.1")?,
    SonameV2::new(
        "lib".parse()?,
        Soname::new("libexample.so".parse()?, Some("1".parse()?))
    ),
);
Source§

type Err = Error

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

impl PartialEq for SonameV2

Source§

fn eq(&self, other: &SonameV2) -> 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 SonameV2

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 SonameV2

Source§

impl StructuralPartialEq for SonameV2

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

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