use crate::cache_file::CacheFileError;
use std::path::Path;
#[cfg(any(
feature = "certified-subnet-catalog-host",
feature = "subnet-catalog-host",
feature = "dashboard-host",
feature = "icrc-host",
feature = "sns-host"
))]
mod json;
#[cfg(feature = "subnet-catalog-host")]
mod output;
#[cfg(feature = "subnet-catalog-host")]
mod path;
#[cfg(feature = "nns-host")]
mod refresh;
#[cfg(all(test, feature = "subnet-catalog-host"))]
mod tests;
#[cfg(feature = "certified-subnet-catalog-host")]
pub use json::canonical_json_matches;
#[cfg(feature = "subnet-catalog-host")]
pub use json::canonical_json_sha256;
#[cfg(any(
feature = "dashboard-host",
feature = "icrc-host",
feature = "subnet-catalog-host",
feature = "sns-host"
))]
pub use json::write_managed_json_pretty_atomically;
#[cfg(feature = "subnet-catalog-host")]
pub use json::{canonical_json_serialized_len, json_error_to_io};
#[cfg(feature = "subnet-catalog-host")]
pub use output::{validate_output_path, write_text_output};
#[cfg(feature = "nns-host")]
pub use refresh::{RefreshCacheWriteRequest, RefreshCacheWriteResult, write_json_refresh_cache};
pub fn ensure_managed_write_size(
path: &Path,
length: u64,
maximum: u64,
) -> Result<(), CacheFileError> {
if length > maximum {
return Err(CacheFileError::WriteLimitExceeded {
path: path.to_path_buf(),
maximum,
});
}
Ok(())
}