509 lines
16 KiB
Rust
509 lines
16 KiB
Rust
|
|
//! Module de streaming audio avec conversion FLAC progressive
|
||
|
|
//!
|
||
|
|
//! Ce module fournit un transformer qui utilise pmoflac pour traiter
|
||
|
|
//! les fichiers audio en vrai streaming, permettant de rendre les fichiers
|
||
|
|
//! FLAC disponibles progressivement pendant le téléchargement.
|
||
|
|
|
||
|
|
use futures_util::StreamExt;
|
||
|
|
use pmocache::StreamTransformer;
|
||
|
|
use std::sync::Arc;
|
||
|
|
use tokio::io::AsyncWriteExt;
|
||
|
|
|
||
|
|
/// Créateur de transformer FLAC avec streaming progressif
|
||
|
|
///
|
||
|
|
/// Ce transformer améliore significativement la disponibilité des fichiers :
|
||
|
|
///
|
||
|
|
/// # Pour les sources FLAC
|
||
|
|
///
|
||
|
|
/// Pipeline streaming complet :
|
||
|
|
/// 1. Télécharger les chunks HTTP au fur et à mesure
|
||
|
|
/// 2. Décoder FLAC → PCM avec pmoflac (streaming)
|
||
|
|
/// 3. Re-encoder PCM → FLAC avec pmoflac (streaming)
|
||
|
|
/// 4. Écrire les frames FLAC immédiatement dans le fichier
|
||
|
|
///
|
||
|
|
/// Résultat : Les fichiers sont disponibles pour lecture en ~100ms au lieu
|
||
|
|
/// d'attendre le téléchargement complet !
|
||
|
|
///
|
||
|
|
/// # Pour les autres formats (MP3, OGG, AAC, etc.)
|
||
|
|
///
|
||
|
|
/// Pipeline hybride :
|
||
|
|
/// 1. Buffer complet du fichier (nécessaire pour Symphonia)
|
||
|
|
/// 2. Décoder avec Symphonia (Read+Seek requis)
|
||
|
|
/// 3. Encoder avec pmoflac en streaming
|
||
|
|
/// 4. Écrire progressivement le FLAC
|
||
|
|
///
|
||
|
|
/// Résultat : Pas de gain sur la latence initiale, mais meilleures performances
|
||
|
|
/// d'encodage et usage mémoire optimisé.
|
||
|
|
pub fn create_streaming_flac_transformer() -> StreamTransformer {
|
||
|
|
Box::new(|input, file, progress| {
|
||
|
|
Box::pin(async move {
|
||
|
|
// TODO: Implémenter la détection de format pour utiliser le pipeline
|
||
|
|
// streaming complet pour les sources FLAC
|
||
|
|
// Pour l'instant, on utilise toujours le pipeline hybride qui fonctionne
|
||
|
|
// pour tous les formats
|
||
|
|
|
||
|
|
tracing::debug!("Using buffered decode + streaming encode pipeline");
|
||
|
|
buffer_and_convert_to_flac(input, file, progress).await
|
||
|
|
})
|
||
|
|
})
|
||
|
|
}
|
||
|
|
|
||
|
|
#[derive(Debug, Clone, Copy)]
|
||
|
|
enum AudioFormat {
|
||
|
|
Flac,
|
||
|
|
Other,
|
||
|
|
}
|
||
|
|
|
||
|
|
/// Détecte le format audio en analysant les premiers bytes
|
||
|
|
async fn detect_format(_input: &pmocache::download::CacheInput) -> Result<AudioFormat, String> {
|
||
|
|
// On ne peut pas peek CacheInput directement sans le consommer,
|
||
|
|
// donc on va détecter pendant le traitement du stream
|
||
|
|
// Pour l'instant, on retourne Other par défaut
|
||
|
|
Ok(AudioFormat::Other)
|
||
|
|
}
|
||
|
|
|
||
|
|
/// Pipeline streaming complet pour FLAC → FLAC
|
||
|
|
///
|
||
|
|
/// Cette fonction implémente le vrai streaming sans buffer :
|
||
|
|
/// - Lecture progressive du stream HTTP
|
||
|
|
/// - Décodage FLAC → PCM au fur et à mesure
|
||
|
|
/// - Re-encodage PCM → FLAC au fur et à mesure
|
||
|
|
/// - Écriture progressive dans le fichier
|
||
|
|
async fn stream_flac_to_flac(
|
||
|
|
input: pmocache::download::CacheInput,
|
||
|
|
mut file: tokio::fs::File,
|
||
|
|
progress: Arc<dyn Fn(u64) + Send + Sync>,
|
||
|
|
) -> Result<(), String> {
|
||
|
|
use pmoflac::{decode_flac_stream, encode_flac_stream, EncoderOptions, PcmFormat};
|
||
|
|
use tokio::io::AsyncReadExt;
|
||
|
|
|
||
|
|
// Convertir le CacheInput en stream
|
||
|
|
let stream = input.into_byte_stream();
|
||
|
|
|
||
|
|
// Créer un lecteur depuis le stream de bytes
|
||
|
|
let reader = StreamToAsyncRead::new(stream);
|
||
|
|
|
||
|
|
// Décoder le FLAC en PCM (streaming)
|
||
|
|
let decoded_stream = decode_flac_stream(reader)
|
||
|
|
.await
|
||
|
|
.map_err(|e| format!("FLAC decode error: {}", e))?;
|
||
|
|
|
||
|
|
let info = decoded_stream.info().clone();
|
||
|
|
tracing::debug!(
|
||
|
|
"FLAC stream info: {} Hz, {} channels, {} bits/sample",
|
||
|
|
info.sample_rate,
|
||
|
|
info.channels,
|
||
|
|
info.bits_per_sample
|
||
|
|
);
|
||
|
|
|
||
|
|
// Créer le format PCM depuis les infos du stream
|
||
|
|
let pcm_format = PcmFormat {
|
||
|
|
sample_rate: info.sample_rate,
|
||
|
|
channels: info.channels,
|
||
|
|
bits_per_sample: info.bits_per_sample,
|
||
|
|
};
|
||
|
|
|
||
|
|
// Options d'encodage
|
||
|
|
let encoder_options = EncoderOptions {
|
||
|
|
compression_level: 5,
|
||
|
|
verify: false,
|
||
|
|
total_samples: info.total_samples,
|
||
|
|
block_size: Some(info.max_block_size as u32),
|
||
|
|
};
|
||
|
|
|
||
|
|
// Re-encoder PCM → FLAC (streaming)
|
||
|
|
// Note: encode_flac_stream consomme decoded_stream
|
||
|
|
let mut encoded_stream = encode_flac_stream(decoded_stream, pcm_format, encoder_options)
|
||
|
|
.await
|
||
|
|
.map_err(|e| format!("FLAC encode error: {}", e))?;
|
||
|
|
|
||
|
|
// Écrire le FLAC encodé dans le fichier au fur et à mesure
|
||
|
|
let mut total_written = 0u64;
|
||
|
|
let mut buffer = vec![0u8; 64 * 1024]; // Buffer de 64 KB
|
||
|
|
|
||
|
|
loop {
|
||
|
|
let n = encoded_stream
|
||
|
|
.read(&mut buffer)
|
||
|
|
.await
|
||
|
|
.map_err(|e| format!("Failed to read encoded FLAC: {}", e))?;
|
||
|
|
|
||
|
|
if n == 0 {
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
|
||
|
|
file.write_all(&buffer[..n])
|
||
|
|
.await
|
||
|
|
.map_err(|e| format!("Failed to write to file: {}", e))?;
|
||
|
|
|
||
|
|
total_written += n as u64;
|
||
|
|
progress(total_written);
|
||
|
|
}
|
||
|
|
|
||
|
|
file.flush()
|
||
|
|
.await
|
||
|
|
.map_err(|e| format!("Failed to flush file: {}", e))?;
|
||
|
|
|
||
|
|
// Attendre que la tâche d'encodage se termine
|
||
|
|
// (l'encoder attend automatiquement que le decoder se termine)
|
||
|
|
encoded_stream
|
||
|
|
.wait()
|
||
|
|
.await
|
||
|
|
.map_err(|e| format!("Encoder/Decoder error: {}", e))?;
|
||
|
|
|
||
|
|
tracing::debug!("Streaming FLAC conversion complete: {} bytes", total_written);
|
||
|
|
|
||
|
|
Ok(())
|
||
|
|
}
|
||
|
|
|
||
|
|
/// Pipeline hybride pour autres formats → FLAC
|
||
|
|
///
|
||
|
|
/// Buffer le fichier complet (nécessaire pour Symphonia), puis encode en streaming
|
||
|
|
async fn buffer_and_convert_to_flac(
|
||
|
|
input: pmocache::download::CacheInput,
|
||
|
|
mut file: tokio::fs::File,
|
||
|
|
progress: Arc<dyn Fn(u64) + Send + Sync>,
|
||
|
|
) -> Result<(), String> {
|
||
|
|
use pmoflac::{encode_flac_stream, EncoderOptions, PcmFormat};
|
||
|
|
|
||
|
|
// 1. Collecter tous les bytes du stream
|
||
|
|
let mut buffer = Vec::new();
|
||
|
|
let mut stream = input.into_byte_stream();
|
||
|
|
|
||
|
|
while let Some(chunk) = stream.next().await {
|
||
|
|
let chunk = chunk.map_err(|e| format!("Stream error: {}", e))?;
|
||
|
|
buffer.extend_from_slice(&chunk);
|
||
|
|
}
|
||
|
|
|
||
|
|
tracing::debug!(
|
||
|
|
"Downloaded {} bytes total, starting conversion",
|
||
|
|
buffer.len()
|
||
|
|
);
|
||
|
|
|
||
|
|
// 2. Si c'est déjà du FLAC, on l'écrit directement
|
||
|
|
if buffer.len() >= 4 && &buffer[0..4] == b"fLaC" {
|
||
|
|
tracing::debug!("Input is already FLAC, writing directly");
|
||
|
|
file.write_all(&buffer)
|
||
|
|
.await
|
||
|
|
.map_err(|e| e.to_string())?;
|
||
|
|
file.flush().await.map_err(|e| e.to_string())?;
|
||
|
|
progress(buffer.len() as u64);
|
||
|
|
return Ok(());
|
||
|
|
}
|
||
|
|
|
||
|
|
tracing::debug!("Converting to FLAC with Symphonia + pmoflac");
|
||
|
|
|
||
|
|
// 3. Décoder l'audio avec Symphonia (dans un blocking task car c'est CPU-intensive)
|
||
|
|
let (samples, channels, sample_rate, bits_per_sample) = tokio::task::spawn_blocking(move || {
|
||
|
|
decode_with_symphonia_sync(buffer)
|
||
|
|
})
|
||
|
|
.await
|
||
|
|
.map_err(|e| format!("Decode task panicked: {}", e))??;
|
||
|
|
|
||
|
|
tracing::debug!(
|
||
|
|
"Decoded {} samples, {} channels, {} Hz, {} bits",
|
||
|
|
samples.len(),
|
||
|
|
channels,
|
||
|
|
sample_rate,
|
||
|
|
bits_per_sample
|
||
|
|
);
|
||
|
|
|
||
|
|
// 4. Convertir les samples i32 en bytes PCM little-endian
|
||
|
|
let pcm_bytes = samples_to_pcm_bytes(&samples, bits_per_sample);
|
||
|
|
|
||
|
|
// 5. Encoder en FLAC avec pmoflac (streaming)
|
||
|
|
let pcm_format = PcmFormat {
|
||
|
|
sample_rate,
|
||
|
|
channels: channels as u8,
|
||
|
|
bits_per_sample: bits_per_sample as u8,
|
||
|
|
};
|
||
|
|
|
||
|
|
let encoder_options = EncoderOptions {
|
||
|
|
compression_level: 5,
|
||
|
|
verify: false,
|
||
|
|
total_samples: Some((samples.len() / channels) as u64),
|
||
|
|
block_size: None,
|
||
|
|
};
|
||
|
|
|
||
|
|
// Utiliser tokio::io::duplex pour éviter le problème de lifetime
|
||
|
|
use std::io::Cursor;
|
||
|
|
let cursor = Cursor::new(pcm_bytes);
|
||
|
|
let mut encoded_stream = encode_flac_stream(cursor, pcm_format, encoder_options)
|
||
|
|
.await
|
||
|
|
.map_err(|e| format!("FLAC encode error: {}", e))?;
|
||
|
|
|
||
|
|
// 6. Écrire le FLAC encodé progressivement
|
||
|
|
use tokio::io::AsyncReadExt;
|
||
|
|
let mut total_written = 0u64;
|
||
|
|
let mut write_buffer = vec![0u8; 64 * 1024];
|
||
|
|
|
||
|
|
loop {
|
||
|
|
let n = encoded_stream
|
||
|
|
.read(&mut write_buffer)
|
||
|
|
.await
|
||
|
|
.map_err(|e| format!("Failed to read encoded FLAC: {}", e))?;
|
||
|
|
|
||
|
|
if n == 0 {
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
|
||
|
|
file.write_all(&write_buffer[..n])
|
||
|
|
.await
|
||
|
|
.map_err(|e| format!("Failed to write to file: {}", e))?;
|
||
|
|
|
||
|
|
total_written += n as u64;
|
||
|
|
progress(total_written);
|
||
|
|
}
|
||
|
|
|
||
|
|
file.flush()
|
||
|
|
.await
|
||
|
|
.map_err(|e| format!("Failed to flush file: {}", e))?;
|
||
|
|
|
||
|
|
encoded_stream
|
||
|
|
.wait()
|
||
|
|
.await
|
||
|
|
.map_err(|e| format!("Encoder error: {}", e))?;
|
||
|
|
|
||
|
|
tracing::debug!("FLAC conversion complete: {} bytes", total_written);
|
||
|
|
|
||
|
|
Ok(())
|
||
|
|
}
|
||
|
|
|
||
|
|
/// Décode un fichier audio avec Symphonia
|
||
|
|
///
|
||
|
|
/// Retourne (samples, channels, sample_rate, bits_per_sample)
|
||
|
|
fn decode_with_symphonia_sync(buffer: Vec<u8>) -> Result<(Vec<i32>, usize, u32, u32), String> {
|
||
|
|
use std::io::Cursor;
|
||
|
|
use symphonia::core::audio::SampleBuffer;
|
||
|
|
use symphonia::core::codecs::{DecoderOptions, CODEC_TYPE_NULL};
|
||
|
|
use symphonia::core::errors::Error as SymphoniaError;
|
||
|
|
use symphonia::core::formats::FormatOptions;
|
||
|
|
use symphonia::core::io::MediaSourceStream;
|
||
|
|
use symphonia::core::meta::MetadataOptions;
|
||
|
|
use symphonia::core::probe::Hint;
|
||
|
|
|
||
|
|
let cursor = Cursor::new(buffer);
|
||
|
|
let mss = MediaSourceStream::new(Box::new(cursor), Default::default());
|
||
|
|
|
||
|
|
let hint = Hint::new();
|
||
|
|
let probed = symphonia::default::get_probe()
|
||
|
|
.format(
|
||
|
|
&hint,
|
||
|
|
mss,
|
||
|
|
&FormatOptions::default(),
|
||
|
|
&MetadataOptions::default(),
|
||
|
|
)
|
||
|
|
.map_err(|e| {
|
||
|
|
format!(
|
||
|
|
"Unable to detect audio format: {}. \
|
||
|
|
Supported formats: MP3, WAV, OGG, FLAC, AAC, ALAC.",
|
||
|
|
e
|
||
|
|
)
|
||
|
|
})?;
|
||
|
|
|
||
|
|
let mut format = probed.format;
|
||
|
|
|
||
|
|
let track = format
|
||
|
|
.tracks()
|
||
|
|
.iter()
|
||
|
|
.find(|t| t.codec_params.codec != CODEC_TYPE_NULL)
|
||
|
|
.ok_or_else(|| {
|
||
|
|
"No audio track found in the file. The file may be corrupted.".to_string()
|
||
|
|
})?;
|
||
|
|
|
||
|
|
let codec_name = format!("{:?}", track.codec_params.codec);
|
||
|
|
tracing::debug!("Detected codec: {}", codec_name);
|
||
|
|
|
||
|
|
let mut decoder = symphonia::default::get_codecs()
|
||
|
|
.make(&track.codec_params, &DecoderOptions::default())
|
||
|
|
.map_err(|e| format!("Codec '{}' is not supported: {}", codec_name, e))?;
|
||
|
|
|
||
|
|
let channels = track
|
||
|
|
.codec_params
|
||
|
|
.channels
|
||
|
|
.ok_or_else(|| "Audio file missing channel information.".to_string())?
|
||
|
|
.count();
|
||
|
|
|
||
|
|
let sample_rate = track
|
||
|
|
.codec_params
|
||
|
|
.sample_rate
|
||
|
|
.ok_or_else(|| "Audio file missing sample rate information.".to_string())?;
|
||
|
|
|
||
|
|
let bits_per_sample = track.codec_params.bits_per_sample.unwrap_or(16);
|
||
|
|
|
||
|
|
let mut samples_i32 = Vec::new();
|
||
|
|
let track_id = track.id;
|
||
|
|
|
||
|
|
// Décoder tous les packets
|
||
|
|
loop {
|
||
|
|
let packet = match format.next_packet() {
|
||
|
|
Ok(packet) => packet,
|
||
|
|
Err(SymphoniaError::ResetRequired) => {
|
||
|
|
decoder.reset();
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
Err(SymphoniaError::IoError(e))
|
||
|
|
if e.kind() == std::io::ErrorKind::UnexpectedEof =>
|
||
|
|
{
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
Err(e) => {
|
||
|
|
return Err(format!(
|
||
|
|
"Failed to read audio data: {}. The file may be corrupted.",
|
||
|
|
e
|
||
|
|
));
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
if packet.track_id() != track_id {
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
|
||
|
|
match decoder.decode(&packet) {
|
||
|
|
Ok(decoded) => {
|
||
|
|
let spec = *decoded.spec();
|
||
|
|
let duration = decoded.capacity() as u64;
|
||
|
|
|
||
|
|
let mut sample_buf = SampleBuffer::<i32>::new(duration, spec);
|
||
|
|
sample_buf.copy_interleaved_ref(decoded);
|
||
|
|
samples_i32.extend_from_slice(sample_buf.samples());
|
||
|
|
}
|
||
|
|
Err(SymphoniaError::DecodeError(e)) => {
|
||
|
|
tracing::warn!("Skipping corrupted audio packet: {}", e);
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
Err(e) => {
|
||
|
|
return Err(format!(
|
||
|
|
"Failed to decode audio: {}. The file may be corrupted.",
|
||
|
|
e
|
||
|
|
));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if samples_i32.is_empty() {
|
||
|
|
return Err("No audio samples could be decoded. The file may be corrupted.".to_string());
|
||
|
|
}
|
||
|
|
|
||
|
|
// Normaliser les samples selon le bits_per_sample
|
||
|
|
let (normalized_samples, target_bits): (Vec<i32>, u32) = match bits_per_sample {
|
||
|
|
0..=16 => {
|
||
|
|
tracing::debug!("Normalizing to 16-bit");
|
||
|
|
let samples = samples_i32.iter().map(|&s| (s >> 16) as i32).collect();
|
||
|
|
(samples, 16)
|
||
|
|
}
|
||
|
|
17..=24 => {
|
||
|
|
tracing::debug!("Normalizing to 24-bit");
|
||
|
|
let samples = samples_i32.iter().map(|&s| (s >> 8) as i32).collect();
|
||
|
|
(samples, 24)
|
||
|
|
}
|
||
|
|
_ => {
|
||
|
|
tracing::debug!("Keeping 32-bit");
|
||
|
|
(samples_i32, 32)
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
Ok((normalized_samples, channels, sample_rate, target_bits))
|
||
|
|
}
|
||
|
|
|
||
|
|
/// Convertit des samples i32 en bytes PCM little-endian
|
||
|
|
fn samples_to_pcm_bytes(samples: &[i32], bits_per_sample: u32) -> Vec<u8> {
|
||
|
|
let bytes_per_sample = (bits_per_sample / 8) as usize;
|
||
|
|
let mut bytes = Vec::with_capacity(samples.len() * bytes_per_sample);
|
||
|
|
|
||
|
|
for &sample in samples {
|
||
|
|
match bits_per_sample {
|
||
|
|
16 => {
|
||
|
|
let s = sample as i16;
|
||
|
|
bytes.extend_from_slice(&s.to_le_bytes());
|
||
|
|
}
|
||
|
|
24 => {
|
||
|
|
let s_bytes = sample.to_le_bytes();
|
||
|
|
bytes.extend_from_slice(&s_bytes[0..3]);
|
||
|
|
}
|
||
|
|
32 => {
|
||
|
|
bytes.extend_from_slice(&sample.to_le_bytes());
|
||
|
|
}
|
||
|
|
_ => {
|
||
|
|
// Fallback pour bits non standard
|
||
|
|
bytes.extend_from_slice(&sample.to_le_bytes());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
bytes
|
||
|
|
}
|
||
|
|
|
||
|
|
/// Adaptateur qui convertit un Stream de Bytes en AsyncRead
|
||
|
|
struct StreamToAsyncRead {
|
||
|
|
stream: futures_util::stream::BoxStream<'static, Result<bytes::Bytes, String>>,
|
||
|
|
current_chunk: Option<bytes::Bytes>,
|
||
|
|
chunk_offset: usize,
|
||
|
|
}
|
||
|
|
|
||
|
|
impl StreamToAsyncRead {
|
||
|
|
fn new(
|
||
|
|
stream: std::pin::Pin<
|
||
|
|
Box<dyn futures_util::Stream<Item = Result<bytes::Bytes, String>> + Send>,
|
||
|
|
>,
|
||
|
|
) -> Self {
|
||
|
|
use futures_util::StreamExt;
|
||
|
|
Self {
|
||
|
|
stream: stream.boxed(),
|
||
|
|
current_chunk: None,
|
||
|
|
chunk_offset: 0,
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
impl tokio::io::AsyncRead for StreamToAsyncRead {
|
||
|
|
fn poll_read(
|
||
|
|
mut self: std::pin::Pin<&mut Self>,
|
||
|
|
cx: &mut std::task::Context<'_>,
|
||
|
|
buf: &mut tokio::io::ReadBuf<'_>,
|
||
|
|
) -> std::task::Poll<std::io::Result<()>> {
|
||
|
|
use futures_util::StreamExt;
|
||
|
|
use std::task::Poll;
|
||
|
|
|
||
|
|
loop {
|
||
|
|
// Si on a un chunk courant, lire dedans
|
||
|
|
if let Some(chunk) = &self.current_chunk {
|
||
|
|
if self.chunk_offset < chunk.len() {
|
||
|
|
let available = chunk.len() - self.chunk_offset;
|
||
|
|
let to_read = std::cmp::min(available, buf.remaining());
|
||
|
|
buf.put_slice(&chunk[self.chunk_offset..self.chunk_offset + to_read]);
|
||
|
|
self.chunk_offset += to_read;
|
||
|
|
return Poll::Ready(Ok(()));
|
||
|
|
} else {
|
||
|
|
// Chunk épuisé, passer au suivant
|
||
|
|
self.current_chunk = None;
|
||
|
|
self.chunk_offset = 0;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// Pas de chunk courant, en récupérer un nouveau
|
||
|
|
match self.stream.poll_next_unpin(cx) {
|
||
|
|
Poll::Ready(Some(Ok(chunk))) => {
|
||
|
|
if chunk.is_empty() {
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
self.current_chunk = Some(chunk);
|
||
|
|
self.chunk_offset = 0;
|
||
|
|
}
|
||
|
|
Poll::Ready(Some(Err(e))) => {
|
||
|
|
return Poll::Ready(Err(std::io::Error::new(
|
||
|
|
std::io::ErrorKind::Other,
|
||
|
|
e,
|
||
|
|
)));
|
||
|
|
}
|
||
|
|
Poll::Ready(None) => {
|
||
|
|
// Stream terminé
|
||
|
|
return Poll::Ready(Ok(()));
|
||
|
|
}
|
||
|
|
Poll::Pending => {
|
||
|
|
return Poll::Pending;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|