rustc_middle/middle/
debugger_visualizer.rs

1use std::path::PathBuf;
2use std::sync::Arc;
3
4use rustc_macros::{Decodable, Encodable, HashStable};
5
6#[derive(HashStable)]
7#[derive(Copy, PartialEq, PartialOrd, Clone, Ord, Eq, Hash, Debug, Encodable, Decodable)]
8pub enum DebuggerVisualizerType {
9    Natvis,
10    GdbPrettyPrinter,
11}
12
13/// A single debugger visualizer file.
14#[derive(HashStable)]
15#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Encodable, Decodable)]
16pub struct DebuggerVisualizerFile {
17    /// The complete debugger visualizer source.
18    pub src: Arc<[u8]>,
19    /// Indicates which visualizer type this targets.
20    pub visualizer_type: DebuggerVisualizerType,
21    /// The file path to the visualizer file. This is used for reporting
22    /// visualizer files in dep-info. Before it is written to crate metadata,
23    /// the path is erased to `None`, so as not to emit potentially privacy
24    /// sensitive data.
25    pub path: Option<PathBuf>,
26}
27
28impl DebuggerVisualizerFile {
29    pub fn new(src: Arc<[u8]>, visualizer_type: DebuggerVisualizerType, path: PathBuf) -> Self {
30        DebuggerVisualizerFile { src, visualizer_type, path: Some(path) }
31    }
32
33    pub fn path_erased(&self) -> Self {
34        DebuggerVisualizerFile {
35            src: Arc::clone(&self.src),
36            visualizer_type: self.visualizer_type,
37            path: None,
38        }
39    }
40}