DarManifest

Struct DarManifest 

Source
pub struct DarManifest { /* private fields */ }
Expand description

Represents a manifest file found inside dar files.

A dar manifest file contains the following fields:

  • Manifest-Version: the version of the manifest file (optional, defaults to Unknown)
  • Created-By: describes what created the dar file containing this manifest file (optional, default to empty string)
  • Main-Dalf: the name of the main dalf file within the dar file (mandatory)
  • Dalfs: a comma separated list of dalf files within this dar file (mandatory)
  • Format: the format of the dalf files in this dar archive (mandatory)
  • Encryption: the encryption type of the dalf files in this dar archive (mandatory)

Note that the main dalf file MUST also be provided in the Dalfs attribute and so that attribute will never be empty.

Implementations§

Source§

impl DarManifest

Source

pub fn new( version: impl Into<DarManifestVersion>, created_by: impl Into<String>, dalf_main: impl Into<String>, dalf_dependencies: Vec<String>, format: impl Into<DarManifestFormat>, encryption: impl Into<DarEncryptionType>, ) -> Self

Crate a DarManifest.

Source

pub fn new_implied( dalf_main: impl Into<String>, dalf_dependencies: Vec<String>, ) -> Self

Create a DarManifest from the supplied main and dalf_dependencies dalf files.

Source

pub fn parse(manifest: &str) -> DamlLfResult<Self>

Create a DarManifest from the supplied manifest string.

Note that all dalf names are stripped of all whitespace.

§Errors

If the provided manifest string cannot be parsed into newline key: value pairs then IoError will be returned.

If the parsed manifest has an invalid format (such as missing a mandatory key) then DarParseError will be returned.

§Examples
let manifest_str = "
           Main-Dalf: A.dalf
           Dalfs: A.dalf
           Format: daml-lf
           Encryption: non-encrypted";
let manifest = DarManifest::parse(&manifest_str[..])?;
assert_eq!(DarManifestVersion::Unknown, manifest.version());
assert_eq!("", manifest.created_by());
assert_eq!("A.dalf", manifest.dalf_main());
assert_eq!(&Vec::<String>::new(), manifest.dalf_dependencies());
assert_eq!(DarManifestFormat::DamlLf, manifest.format());
assert_eq!(DarEncryptionType::NotEncrypted, manifest.encryption());
Source

pub fn render(&self) -> String

Render this DarManifest

Source

pub const fn version(&self) -> DarManifestVersion

The version of the manifest.

Source

pub fn created_by(&self) -> &str

Describes who created the dar file which contains this manifest file.

Source

pub fn dalf_main(&self) -> &str

The name of the main dalf archive within the dar file containing this manifest file.

Source

pub const fn dalf_dependencies(&self) -> &Vec<String>

A list of names of the dalf_dependencies dalf archives within the dar file containing this manifest file.

Source

pub const fn format(&self) -> DarManifestFormat

The format of the dar which contains this manifest file.

Source

pub const fn encryption(&self) -> DarEncryptionType

The encryption type of the dar which contains this manifest file.

Trait Implementations§

Source§

impl Clone for DarManifest

Source§

fn clone(&self) -> DarManifest

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 DarManifest

Source§

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

Formats the value using the given formatter. Read more

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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, 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.