Skip to main content

mermaid_model/utils/
mod.rs

1// Gateway module for utils - follows the Train Station Pattern
2// All external access must go through this gateway
3
4// Private submodules - not directly accessible from outside
5mod auth;
6mod bounded;
7mod confirm;
8pub mod credentials;
9mod host_memory;
10mod logger;
11mod ndjson;
12mod net;
13mod open;
14mod private_tmp;
15mod proc;
16mod retry;
17pub mod serde_base64;
18mod sse;
19mod task;
20mod text;
21mod timestamp;
22
23// Public re-exports - the ONLY way to access utils functionality
24pub use auth::{
25    provider_key_source, resolve_api_key, resolve_api_key_with_fallback, resolve_provider_key,
26    resolve_provider_key_with_fallback,
27};
28pub use bounded::{CappedLine, read_capped, read_file_capped, read_line_capped};
29pub use confirm::{confirm_or_refuse, is_affirmative, should_refuse_noninteractive};
30pub use credentials::{CredentialStore, default_store};
31pub use host_memory::{gpu_vram_bytes, system_ram_bytes};
32pub use logger::{
33    TraceRing, init_logger, log_debug, log_error, log_file_path, log_info, log_progress, log_warn,
34    trace_ring,
35};
36pub use ndjson::drain_complete_lines;
37pub use net::{HostClass, classify_host};
38pub use open::open_file;
39pub use private_tmp::private_temp_dir;
40#[cfg(target_os = "windows")]
41pub use proc::{CREATE_NEW_PROCESS_GROUP, CREATE_NO_WINDOW};
42pub use proc::{
43    Grace, output_with_timeout, terminate_tree, terminate_tree_blocking, write_stdin_with_timeout,
44};
45// Redaction has exactly one implementation, in `mermaid-runtime`, so every
46// SQLite repository enforces the same rules whoever calls it. Forwarded here
47// rather than wrapped: the wrapper file was 77 lines of which 70 were tests
48// re-testing another crate, and its forward silently dropped
49// `redact_json_text` so that one name did not resolve while its three
50// siblings did.
51pub use mermaid_runtime::{
52    redact_json, redact_json_text, redact_secrets, sanitize_url_for_display,
53};
54pub use retry::jitter;
55pub use sse::drain_sse_events;
56pub use task::{AbortOnDrop, join_logged, spawn_guarded};
57pub use text::{
58    continuation_overlap, format_duration, truncate_content, truncate_middle,
59    truncate_middle_bytes, truncate_web_content,
60};
61pub use timestamp::format_relative_timestamp;