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: String§payload: DamlLfArchivePayload§hash_function: DamlLfHashFunction§hash: StringImplementations§
Source§impl DamlLfArchive
impl DamlLfArchive
Sourcepub fn new(
name: impl Into<String>,
payload: impl Into<DamlLfArchivePayload>,
hash_function: impl Into<DamlLfHashFunction>,
hash: impl Into<String>,
) -> Self
pub fn new( name: impl Into<String>, payload: impl Into<DamlLfArchivePayload>, hash_function: impl Into<DamlLfHashFunction>, hash: impl Into<String>, ) -> Self
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.
Sourcepub fn from_bytes(bytes: impl Into<Bytes>) -> DamlLfResult<Self>
pub fn from_bytes(bytes: impl Into<Bytes>) -> DamlLfResult<Self>
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());Sourcepub fn from_bytes_named(
name: impl Into<String>,
bytes: impl Into<Bytes>,
) -> DamlLfResult<Self>
pub fn from_bytes_named( name: impl Into<String>, bytes: impl Into<Bytes>, ) -> DamlLfResult<Self>
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());Sourcepub fn from_file(dalf_path: impl AsRef<Path>) -> DamlLfResult<Self>
pub fn from_file(dalf_path: impl AsRef<Path>) -> DamlLfResult<Self>
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());Sourcepub fn apply<R, F>(&self, f: F) -> DamlLfResult<R>where
F: FnOnce(&DamlPackage<'_>) -> R,
pub fn apply<R, F>(&self, f: F) -> DamlLfResult<R>where
F: FnOnce(&DamlPackage<'_>) -> R,
Create a DamlArchive from a DamlLfArchive and apply it to f.
See DarFile::apply for details.
Sourcepub const fn payload(&self) -> &DamlLfArchivePayload
pub const fn payload(&self) -> &DamlLfArchivePayload
The payload (aka “package”) contained within this archive.
Sourcepub const fn hash_function(&self) -> &DamlLfHashFunction
pub const fn hash_function(&self) -> &DamlLfHashFunction
The hashing function used to generate this archives hash.
Trait Implementations§
Source§impl Clone for DamlLfArchive
impl Clone for DamlLfArchive
Source§fn clone(&self) -> DamlLfArchive
fn clone(&self) -> DamlLfArchive
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for DamlLfArchive
impl RefUnwindSafe for DamlLfArchive
impl Send for DamlLfArchive
impl Sync for DamlLfArchive
impl Unpin for DamlLfArchive
impl UnwindSafe for DamlLfArchive
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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