#[non_exhaustive]pub enum Protocol {
Anthropic,
OpenAiCompatible,
}Expand description
对话接口协议:决定走 /v1/messages 还是 /v1/chat/completions。
🔴 线格式是 "anthropic" / "openai_compatible",与 Protocol::as_str 同一套拼写。
此前靠 rename_all = "snake_case" 自动推出 "open_ai_compatible",
下游存的是 openai_compatible,前端不得不写一层转换 —— 两种拼写并存,
迟早有一处直接透传而静默错配。
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Anthropic
Anthropic 原生:/v1/messages + x-api-key
OpenAiCompatible
OpenAI 兼容:/v1/chat/completions + Authorization: Bearer
Implementations§
Source§impl Protocol
impl Protocol
Sourcepub fn parse(s: &str) -> Option<Self>
pub fn parse(s: &str) -> Option<Self>
从字符串解析;认不出返回 None。
只收规范拼写 —— 这是给「读自己存的值」用的,存进去的一定是 Self::as_str。
解析别人家分享来的配置("openai" / "custom" 之类)请用
crate::protocol::parse_profile,那边有宽松的别名映射。
Sourcepub const fn default_base_url(self) -> &'static str
pub const fn default_base_url(self) -> &'static str
用户没填 base_url 时的官方端点。
🔴 带版本段:crate::endpoint 原样拼接、不做推断,少一段就是 404。
Trait Implementations§
impl Copy for Protocol
Source§impl<'de> Deserialize<'de> for Protocol
impl<'de> Deserialize<'de> for Protocol
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Protocol
impl StructuralPartialEq for Protocol
Auto Trait Implementations§
impl Freeze for Protocol
impl RefUnwindSafe for Protocol
impl Send for Protocol
impl Sync for Protocol
impl Unpin for Protocol
impl UnsafeUnpin for Protocol
impl UnwindSafe for Protocol
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more