Skip to content

Commit

Permalink
Merge pull request #2116 from AleoHQ/feat/parameter-metadata
Browse files Browse the repository at this point in the history
Make the parameter metadata accessible
  • Loading branch information
howardwu authored Oct 24, 2023
2 parents 4e289d4 + 281a181 commit b9f3fcb
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions parameters/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,11 @@ macro_rules! impl_local {
pub struct $name;

impl $name {
pub fn load_bytes() -> Result<Vec<u8>, $crate::errors::ParameterError> {
const METADATA: &'static str = include_str!(concat!($local_dir, $fname, ".metadata"));
pub const METADATA: &'static str = include_str!(concat!($local_dir, $fname, ".metadata"));

pub fn load_bytes() -> Result<Vec<u8>, $crate::errors::ParameterError> {
let metadata: serde_json::Value =
serde_json::from_str(METADATA).expect("Metadata was not well-formatted");
serde_json::from_str(Self::METADATA).expect("Metadata was not well-formatted");
let expected_checksum: String =
metadata["checksum"].as_str().expect("Failed to parse checksum").to_string();
let expected_size: usize =
Expand All @@ -282,11 +282,11 @@ macro_rules! impl_local {
pub struct $name;

impl $name {
pub fn load_bytes() -> Result<Vec<u8>, $crate::errors::ParameterError> {
const METADATA: &'static str = include_str!(concat!($local_dir, $fname, ".metadata"));
pub const METADATA: &'static str = include_str!(concat!($local_dir, $fname, ".metadata"));

pub fn load_bytes() -> Result<Vec<u8>, $crate::errors::ParameterError> {
let metadata: serde_json::Value =
serde_json::from_str(METADATA).expect("Metadata was not well-formatted");
serde_json::from_str(Self::METADATA).expect("Metadata was not well-formatted");
let expected_checksum: String =
metadata[concat!($ftype, "_checksum")].as_str().expect("Failed to parse checksum").to_string();
let expected_size: usize =
Expand Down Expand Up @@ -315,13 +315,13 @@ macro_rules! impl_remote {
pub struct $name;

impl $name {
pub const METADATA: &'static str = include_str!(concat!($local_dir, $fname, ".metadata"));

impl_store_and_remote_fetch!();

pub fn load_bytes() -> Result<Vec<u8>, $crate::errors::ParameterError> {
const METADATA: &'static str = include_str!(concat!($local_dir, $fname, ".metadata"));

let metadata: serde_json::Value =
serde_json::from_str(METADATA).expect("Metadata was not well-formatted");
serde_json::from_str(Self::METADATA).expect("Metadata was not well-formatted");
let expected_checksum: String =
metadata["checksum"].as_str().expect("Failed to parse checksum").to_string();
let expected_size: usize =
Expand Down Expand Up @@ -355,13 +355,13 @@ macro_rules! impl_remote {
pub struct $name;

impl $name {
pub const METADATA: &'static str = include_str!(concat!($local_dir, $fname, ".metadata"));

impl_store_and_remote_fetch!();

pub fn load_bytes() -> Result<Vec<u8>, $crate::errors::ParameterError> {
const METADATA: &'static str = include_str!(concat!($local_dir, $fname, ".metadata"));

let metadata: serde_json::Value =
serde_json::from_str(METADATA).expect("Metadata was not well-formatted");
serde_json::from_str(Self::METADATA).expect("Metadata was not well-formatted");
let expected_checksum: String =
metadata[concat!($ftype, "_checksum")].as_str().expect("Failed to parse checksum").to_string();
let expected_size: usize =
Expand Down

0 comments on commit b9f3fcb

Please sign in to comment.