heapdump_snapshot/
lib.rs

1// Copyright 2023 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5use fidl_fuchsia_memory_heapdump_client as fheapdump_client;
6use thiserror::Error;
7
8mod snapshot;
9pub use snapshot::{Allocation, ExecutableRegion, Snapshot, StackTrace, ThreadInfo};
10
11mod streamer;
12pub use streamer::Streamer;
13
14#[derive(Debug, Error)]
15pub enum Error {
16    #[error("Missing expected field {} in {}", .field, .container)]
17    MissingField { container: &'static str, field: &'static str },
18    #[error("SnapshotReceiver stream ended unexpectedly")]
19    UnexpectedEndOfStream,
20    #[error("SnapshotReceiver stream contains an unknown element type")]
21    UnexpectedElementType,
22    #[error("SnapshotReceiver stream contains conflicting {} elements", .element_type)]
23    ConflictingElement { element_type: &'static str },
24    #[error("SnapshotReceiver stream contains a cross-reference to a non-existing {} element",
25        .element_type)]
26    InvalidCrossReference { element_type: &'static str },
27    #[error("Zircon error: {}", .0)]
28    ZxError(#[from] zx_status::Status),
29    #[error("FIDL error: {}", .0)]
30    FidlError(#[from] fidl::Error),
31    #[error("Collector error: {:?}", .0)]
32    CollectorError(fheapdump_client::CollectorError),
33}