logo
pub struct DamlLfArchive {
    pub name: String,
    pub payload: DamlLfArchivePayload,
    pub hash_function: DamlLfHashFunction,
    pub hash: String,
}
Expand description

A Daml LF archive (aka a dalf file).

A DamlLfArchive contains a name, a payload (aka “package”), a hash (aka “package id”) of that payload for a given hash_function.

Fields

name: Stringpayload: DamlLfArchivePayloadhash_function: DamlLfHashFunctionhash: String

Implementations

Create an archive from an existing payload, hash_function and hash.

Note that this method does not validate that the supplied hash is valid for the supplied payload and hash_function and thus could create an invalid archive.

Deserialize an archive from the protobuf binary representation with a default name.

Deserialize the supplied protobuf bytes into a DamlLfArchive. The embedded payload (bytes) will also be deserialized into a DamlLfArchivePayload.

Errors

If the provided bytes cannot be deserialized into an archive (or the embedded payload cannot be deserialized into a DamlLfArchivePayload) then DamlLfParseError will be returned.

If the embedded payload is not of a known version then UnknownVersion will be returned.

Archives of Daml LF v0 are not supported and will result in a UnsupportedVersion being returned.

Examples
let buffer = Vec::<u8>::new();
let archive = DamlLfArchive::from_bytes(buffer)?;
assert_eq!(&DamlLfHashFunction::Sha256, archive.hash_function());

Deserialize a named archive from the protobuf binary representation.

Deserialize the supplied protobuf bytes into a DamlLfArchive. The embedded payload (bytes) will also be deserialized into a DamlLfArchivePayload.

Errors

If the provided bytes cannot be deserialized into an archive (or the embedded payload cannot be deserialized into a DamlLfArchivePayload) then DamlLfParseError will be returned.

If the embedded payload is not of a known version then UnknownVersion will be returned.

Archives of Daml LF v0 are not supported and will result in a UnsupportedVersion being returned.

Examples
let buffer = Vec::<u8>::new();
let archive = DamlLfArchive::from_bytes_named("foo", buffer)?;
assert_eq!(&DamlLfHashFunction::Sha256, archive.hash_function());
assert_eq!("foo", archive.name());

Read and parse an archive from a dalf file.

Errors

If the provided file cannot be read an IOError will be returned which contains the underlying IO error.

If the contents of the file cannot be deserialized into an archive (or the embedded payload cannot be deserialized into a DamlLfArchivePayload) then DamlLfParseError will be returned.

If the embedded payload is not of a known version then UnknownVersion will be returned.

Archives of Daml LF v0 are not supported and will result in a UnsupportedVersion being returned.

Examples
let archive = DamlLfArchive::from_file("Example.dalf")?;
assert_eq!(&DamlLfHashFunction::Sha256, archive.hash_function());
assert_eq!("Example", archive.name());

Create a DamlArchive from a DamlLfArchive and apply it to f.

See DarFile::apply for details.

The name of this archive.

The payload (aka “package”) contained within this archive.

The hashing function used to generate this archives hash.

The hash of this archive (aka “package id”).

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.