linera-sdk 0.15.17

Library to support developing Linera applications in Rust.
Documentation
// Copyright (c) Zefchain Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

//! Conversions from types declared in [`linera-sdk`] to types generated by [`wit-bindgen`].

use linera_base::{crypto::CryptoHash, identifiers::ApplicationId};

use super::wit::service_runtime_api as wit_service_api;

impl From<CryptoHash> for wit_service_api::CryptoHash {
    fn from(hash_value: CryptoHash) -> Self {
        let parts = <[u64; 4]>::from(hash_value);

        wit_service_api::CryptoHash {
            part1: parts[0],
            part2: parts[1],
            part3: parts[2],
            part4: parts[3],
        }
    }
}

impl From<ApplicationId> for wit_service_api::ApplicationId {
    fn from(application_id: ApplicationId) -> Self {
        wit_service_api::ApplicationId {
            application_description_hash: application_id.application_description_hash.into(),
        }
    }
}