Skip to main content

aria_primitives/
lib.rs

1//! Foundational capabilities shared by Aria subsystems.
2
3#![cfg_attr(docsrs, feature(doc_cfg))]
4
5pub mod cancel;
6#[cfg(not(target_family = "wasm"))]
7pub mod file_inspection;
8pub mod lazy;
9#[cfg(not(target_family = "wasm"))]
10pub mod local_socket;
11#[cfg(not(target_family = "wasm"))]
12pub mod private_document;
13#[cfg(not(target_family = "wasm"))]
14pub mod private_fs;
15// iOS forbids spawning a child process, so nothing built on one exists there.
16#[cfg(not(any(target_os = "ios", target_family = "wasm")))]
17pub mod process;
18pub mod slot;
19#[cfg(not(target_family = "wasm"))]
20pub mod thread;
21pub mod user_home;
22#[cfg(not(target_family = "wasm"))]
23pub mod wakeup;
24
25/// An error and every cause under it, joined into one line. A cause the
26/// message already ends with is not repeated.
27pub fn error_chain(error: &dyn std::error::Error) -> String {
28    let mut message = error.to_string();
29    let mut cause = error.source();
30    while let Some(error) = cause {
31        let text = error.to_string();
32        if !message.ends_with(&text) {
33            message.push_str(": ");
34            message.push_str(&text);
35        }
36        cause = error.source();
37    }
38    message
39}