Skip to main content

slicec/grammar/elements/
operation.rs

1// Copyright (c) ZeroC, Inc.
2
3use super::super::*;
4use crate::slice_file::Span;
5use crate::utils::ptr_util::WeakPtr;
6
7#[derive(Debug)]
8pub struct Operation {
9    pub identifier: Identifier,
10    pub parameters: Vec<WeakPtr<Parameter>>,
11    pub return_type: Vec<WeakPtr<Parameter>>,
12    pub is_idempotent: bool,
13    pub parent: WeakPtr<Interface>,
14    pub scope: Scope,
15    pub attributes: Vec<WeakPtr<Attribute>>,
16    pub comment: Option<DocComment>,
17    pub span: Span,
18}
19
20impl Operation {
21    pub fn parameters(&self) -> Vec<&Parameter> {
22        self.parameters.iter().map(WeakPtr::borrow).collect()
23    }
24
25    pub fn return_members(&self) -> Vec<&Parameter> {
26        self.return_type.iter().map(WeakPtr::borrow).collect()
27    }
28}
29
30implement_Element_for!(Operation, "operation");
31implement_Attributable_for!(@Contained Operation);
32implement_Entity_for!(Operation);
33implement_Commentable_for!(Operation);
34implement_Contained_for!(Operation, Interface);