nexus_sdk/legacy/
views.rs

1use crate::error::IOError;
2use crate::legacy::traits::LegacyViewable;
3use serde::de::DeserializeOwned;
4
5/// A view capturing the unchecked output of a zkVM execution.
6///
7/// By _unchecked_, it is meant that although the zkVM proves that the guest program correctly wrote to the output tape, there is no cryptographic
8/// guarantee that the return of `output()` as accessed by the host program contains the same values that were written.
9#[derive(Debug, Default)]
10pub struct UncheckedView {
11    pub(crate) out: Vec<u8>,
12    pub(crate) logs: Vec<String>,
13}
14
15impl LegacyViewable for UncheckedView {
16    fn output<U: DeserializeOwned>(&self) -> Result<U, IOError> {
17        Ok(postcard::from_bytes::<U>(self.out.as_slice())?)
18    }
19
20    fn logs(&self) -> &Vec<String> {
21        &self.logs
22    }
23}