Skip to main content

tea_protocol/
model.rs

1use std::fmt;
2
3use serde::{Deserialize, Serialize};
4
5use crate::{ModelId, ProviderId};
6
7/// Complete canonical identity of one model advertised by one provider.
8#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
9#[serde(rename_all = "camelCase", deny_unknown_fields)]
10pub struct ModelRef {
11    provider_id: ProviderId,
12    model_id: ModelId,
13}
14
15impl ModelRef {
16    /// Creates a provider-qualified model identity.
17    #[must_use]
18    pub const fn new(provider_id: ProviderId, model_id: ModelId) -> Self {
19        Self {
20            provider_id,
21            model_id,
22        }
23    }
24
25    /// Returns the provider selector.
26    #[must_use]
27    pub const fn provider_id(&self) -> &ProviderId {
28        &self.provider_id
29    }
30
31    /// Returns the provider-local model selector.
32    #[must_use]
33    pub const fn model_id(&self) -> &ModelId {
34        &self.model_id
35    }
36}
37
38impl fmt::Display for ModelRef {
39    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
40        write!(formatter, "{}:{}", self.provider_id, self.model_id)
41    }
42}