返回 DeepSeek-TUI-2026
llm_client.rs
根目录 / crates / tui / tests / support / llm_client.rs
1 //! Test-only mirror of the production `llm_client` module surface.
2 //!
3 //! The integration test under `tests/integration_mock_llm.rs` includes this
4 //! file as `mod llm_client` and `mock.rs` as the nested submodule. Doing it
5 //! this way means `mock.rs`'s `super::{LlmClient, StreamEventBox}` paths
6 //! resolve cleanly — they refer to the trait + alias declared right here.
7 //!
8 //! The trait shape MUST stay 1:1 with the real one in
9 //! `crates/tui/src/llm_client/mod.rs`. If the production trait grows a method,
10 //! mirror it here so `mock.rs` (the same source file shipped in the binary)
11 //! still satisfies it.
12
13 use anyhow::Result;
14 use std::pin::Pin;
15
16 use crate::models::{MessageRequest, MessageResponse, StreamEvent};
17
18 pub type StreamEventBox =
19 Pin<Box<dyn futures_util::Stream<Item = Result<StreamEvent>> + Send + 'static>>;
20
21 #[allow(async_fn_in_trait, dead_code)]
22 pub trait LlmClient: Send + Sync {
23 fn provider_name(&self) -> &'static str;
24 fn model(&self) -> &str;
25 async fn create_message(&self, request: MessageRequest) -> Result<MessageResponse>;
26 async fn create_message_stream(&self, request: MessageRequest) -> Result<StreamEventBox>;
27 async fn health_check(&self) -> Result<bool> {
28 Ok(true)
29 }
30 }
31
32 #[path = "../../src/llm_client/mock.rs"]
33 pub mod mock;
34
34 lines RUST