ice_rs/slice/
function_throws.rs

1use quote::{__private::TokenStream, quote};
2
3use super::types::IceType;
4
5#[derive(Clone, Debug)]
6pub struct FunctionThrows {
7    pub r#type: Option<IceType>,
8}
9
10impl FunctionThrows {
11    pub fn new(r#type: IceType) -> FunctionThrows {
12        FunctionThrows {
13            r#type: Some(r#type)
14        }
15    }
16
17    pub fn empty() -> FunctionThrows {
18        FunctionThrows {
19            r#type: None
20        }
21    }
22
23    pub fn token(&self) -> TokenStream {
24        match &self.r#type {
25            Some(throw) => {
26                throw.token()                
27            },
28            _ => quote! {
29                ProtocolError
30            }
31        }   
32    }
33}