mithril_client_cli/utils/
mod.rs

1//! Utilities module
2//! This module contains tools needed for the commands layer.
3
4mod archive_unpacker;
5mod cardano_db;
6mod cardano_db_download_checker;
7mod expander;
8mod feedback_receiver;
9mod forced_era_fetcher;
10mod fs;
11mod github_release_retriever;
12mod http_downloader;
13mod multi_download_progress_reporter;
14mod progress_reporter;
15
16pub use archive_unpacker::*;
17pub use cardano_db::*;
18pub use cardano_db_download_checker::*;
19pub use expander::*;
20pub use feedback_receiver::*;
21pub use forced_era_fetcher::*;
22pub use fs::*;
23pub use github_release_retriever::*;
24pub use http_downloader::*;
25pub use multi_download_progress_reporter::*;
26pub use progress_reporter::*;
27
28use anyhow::anyhow;
29use mithril_client::MithrilResult;
30use std::path::Path;
31
32/// The key used to store the caution message when printing a JSON directly to stderr
33pub(crate) const JSON_CAUTION_KEY: &str = "caution";
34
35/// Converts a [Path] to a [String], returning an error if the path is not valid UTF-8.
36pub(crate) fn path_to_string(path: &Path) -> MithrilResult<String> {
37    let path = path
38        .to_str()
39        .ok_or_else(|| {
40            anyhow!(
41                "Path '{}' contains invalid UTF-8 characters.",
42                path.display()
43            )
44        })?
45        .to_string();
46
47    Ok(path)
48}