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::{
10    Allocation, ExecutableRegion, Snapshot, SnapshotWithHeader, StackTrace, ThreadInfo,
11};
12
13mod streamer;
14pub use streamer::Streamer;
15
16#[derive(Debug, Error)]
17pub enum Error {
18    #[error("Missing expected field {} in {}", .field, .container)]
19    MissingField { container: &'static str, field: &'static str },
20    #[error("SnapshotReceiver stream ended unexpectedly")]
21    UnexpectedEndOfStream,
22    #[error("SnapshotReceiver stream contains an unknown element type")]
23    UnexpectedElementType,
24    #[error("SnapshotReceiver stream contains conflicting {} elements", .element_type)]
25    ConflictingElement { element_type: &'static str },
26    #[error("SnapshotReceiver stream contains a cross-reference to a non-existing {} element",
27        .element_type)]
28    InvalidCrossReference { element_type: &'static str },
29    #[cfg(fuchsia_api_level_at_least = "HEAD")]
30    #[error("A header was expected in the SnapshotReceiver stream")]
31    HeaderExpected,
32    #[error("Zircon error: {}", .0)]
33    ZxError(#[from] zx_status::Status),
34    #[error("FIDL error: {}", .0)]
35    FidlError(#[from] fidl::Error),
36    #[error("Collector error: {:?}", .0)]
37    CollectorError(fheapdump_client::CollectorError),
38}