use serde::{Deserialize, Serialize};

use crate::model::ProtoMethod;

#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ProtoService {
    pub package: String,
    pub name: String,
    pub methods: Vec<ProtoMethod>,
}

impl ProtoService {
    pub fn unary_methods(&self) -> impl Iterator<Item = &ProtoMethod> {
        self.methods.iter().filter(|method| method.is_unary())
    }
}
