Skip to main content

gproxy_protocol/adapt/generate/state/
chat_form.rs

1use super::*;
2
3/// Actual native Chat wire form. LegacyFunction uses its actual name and has
4/// no native call/item ID; its client alias says so.
5#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
6pub enum ChatCallForm {
7    Modern,
8    LegacyFunction,
9}
10
11impl GenerationToolReplay {
12    pub(crate) fn original_chat_calls(&self) -> BTreeMap<String, (String, String)> {
13        self.chat_forms
14            .iter()
15            .filter(|(_, form)| **form == ChatCallForm::Modern)
16            .filter_map(|(client, _)| {
17                self.original_call_ids
18                    .get(client)
19                    .zip(self.names.get(client))
20                    .map(|(id, name)| (client.clone(), (id.clone(), name.clone())))
21            })
22            .collect()
23    }
24    pub(crate) fn legacy_chat_calls(&self) -> BTreeMap<String, String> {
25        self.chat_forms
26            .iter()
27            .filter(|(_, form)| **form == ChatCallForm::LegacyFunction)
28            .filter_map(|(id, _)| self.names.get(id).map(|name| (id.clone(), name.clone())))
29            .collect()
30    }
31}