snarkvm_synthesizer_program/view/output/mod.rs
1// Copyright (c) 2019-2026 Provable Inc.
2// This file is part of the snarkVM library.
3
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at:
7
8// http://www.apache.org/licenses/LICENSE-2.0
9
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16mod bytes;
17mod parse;
18
19use crate::Operand;
20
21use console::{network::prelude::*, program::FinalizeType};
22
23/// An output statement defines an output of a view function.
24/// An output statement is of the form `output {operand} as {finalize_type};`.
25///
26/// The finalize type carries the same plaintext-only constraints as finalize inputs:
27/// futures and dynamic futures are rejected at construction time.
28#[derive(Clone, PartialEq, Eq, Hash)]
29pub struct Output<N: Network> {
30 /// The output operand.
31 operand: Operand<N>,
32 /// The output finalize type.
33 finalize_type: FinalizeType<N>,
34}
35
36impl<N: Network> Output<N> {
37 /// Returns the output operand.
38 #[inline]
39 pub const fn operand(&self) -> &Operand<N> {
40 &self.operand
41 }
42
43 /// Returns the output finalize type.
44 #[inline]
45 pub const fn finalize_type(&self) -> &FinalizeType<N> {
46 &self.finalize_type
47 }
48}
49
50impl<N: Network> TypeName for Output<N> {
51 #[inline]
52 fn type_name() -> &'static str {
53 "output"
54 }
55}