nexus_sdk/legacy/
views.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use crate::error::IOError;
use crate::legacy::traits::LegacyViewable;
use serde::de::DeserializeOwned;

/// A view capturing the unchecked output of a zkVM execution.
///
/// By _unchecked_, it is meant that although the zkVM proves that the guest program correctly wrote to the output tape, there is no cryptographic
/// guarantee that the return of `output()` as accessed by the host program contains the same values that were written.
#[derive(Debug, Default)]
pub struct UncheckedView {
    pub(crate) out: Vec<u8>,
    pub(crate) logs: Vec<String>,
}

impl LegacyViewable for UncheckedView {
    fn output<U: DeserializeOwned>(&self) -> Result<U, IOError> {
        Ok(postcard::from_bytes::<U>(self.out.as_slice())?)
    }

    fn logs(&self) -> &Vec<String> {
        &self.logs
    }
}