Files
IdeaSDK/crates/app-tauri/src/stream.rs
Blomios c8fef2a76a refactor(backend): abstraire le sink de stream hors de tauri::ipc::Channel (#13)
Lot B2 du chantier server/client mode : le cœur backend émet désormais ses
flux via une abstraction de sink agnostique, sans dépendre directement de
tauri::ipc::Channel, préalable au futur serveur web + PTY WebSocket.

- crates/backend : abstraction de sink (stream.rs) câblée dans lib.rs.
- crates/app-tauri : implémentation Tauri du sink (stream.rs) et adaptation
  des surfaces lib.rs, pty.rs, chat.rs.
- Nettoyage clippy des 2 warnings B2.

Validé : cargo check --workspace vert, tests backend/app-tauri verts,
cœur agnostique Tauri, clippy B2 propre.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-15 12:50:29 +02:00

32 lines
921 B
Rust

//! Tauri implementation of the shared outbound stream sink contract.
//!
//! The backend core owns the transport-agnostic [`backend::stream::OutputSink`]
//! abstraction. This adapter is the only layer that turns it into a concrete
//! [`tauri::ipc::Channel`] send.
use backend::stream::{OutputSink, OutputSinkError};
use serde::Serialize;
use tauri::ipc::Channel;
/// [`OutputSink`] backed by a per-attach Tauri IPC [`Channel`].
pub struct TauriChannelSink<T> {
channel: Channel<T>,
}
impl<T> TauriChannelSink<T> {
/// Wraps a Tauri IPC channel as a shared backend stream sink.
#[must_use]
pub fn new(channel: Channel<T>) -> Self {
Self { channel }
}
}
impl<T> OutputSink<T> for TauriChannelSink<T>
where
T: Serialize + Send + Sync + 'static,
{
fn send(&self, item: T) -> Result<(), OutputSinkError> {
self.channel.send(item).map_err(|_| OutputSinkError::Closed)
}
}