INNER CODE UNIT · Rust
new_streaming_connection
aome510/spotify-player · spotify_player/src/client/mod.rs:323
pub async fn new_streaming_connection(
&self,
state: SharedState,
session: librespot_core::Session,
creds: librespot_core::authentication::Credentials,
) -> Result<()> {
let new_conn =
crate::streaming::new_connection(self.clone(), state, session, creds).await?;
let mut stream_conn = self.stream_conn.lock();
// shutdown old streaming connection and replace it with a new connection
if let Some(conn) = stream_conn.as_ref() {
if let Err(err) = conn.shutdown() {
log::error!("Failed to shutdown old streaming connection: {err:#}");
}
}
*stream_conn = Some(new_conn);
Ok(())
}