File size: 762 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use std::fmt::{self, Display};

use anyhow::anyhow;

use crate::{RawVc, backend::TurboTasksExecutionError};

/// A helper type representing the output of a resolved task.
#[derive(Clone, Debug)]
pub enum OutputContent {
    Link(RawVc),
    Error(TurboTasksExecutionError),
}

impl OutputContent {
    pub fn as_read_result(&self) -> anyhow::Result<RawVc> {
        match &self {
            Self::Error(err) => Err(anyhow!(err.clone())),
            Self::Link(raw_vc) => Ok(*raw_vc),
        }
    }
}

impl Display for OutputContent {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            Self::Link(raw_vc) => write!(f, "link {raw_vc:?}"),
            Self::Error(err) => write!(f, "error {err}"),
        }
    }
}