mirror of
https://github.com/librespot-org/librespot.git
synced 2025-10-03 09:49:31 +02:00
Remove usage of deprecated BoxFuture, BoxStream and BoxSink
This commit is contained in:
parent
0bdf9aa080
commit
5237203899
8 changed files with 36 additions and 38 deletions
|
@ -4,7 +4,7 @@ mod handshake;
|
|||
pub use self::codec::APCodec;
|
||||
pub use self::handshake::handshake;
|
||||
|
||||
use futures::{Future, Sink, Stream, BoxFuture};
|
||||
use futures::{Future, Sink, Stream};
|
||||
use std::io;
|
||||
use std::net::ToSocketAddrs;
|
||||
use tokio_core::net::TcpStream;
|
||||
|
@ -17,18 +17,18 @@ use version;
|
|||
|
||||
pub type Transport = Framed<TcpStream, APCodec>;
|
||||
|
||||
pub fn connect<A: ToSocketAddrs>(addr: A, handle: &Handle) -> BoxFuture<Transport, io::Error> {
|
||||
pub fn connect<A: ToSocketAddrs>(addr: A, handle: &Handle) -> Box<Future<Item = Transport, Error = io::Error>> {
|
||||
let addr = addr.to_socket_addrs().unwrap().next().unwrap();
|
||||
let socket = TcpStream::connect(&addr, handle);
|
||||
let connection = socket.and_then(|socket| {
|
||||
handshake(socket)
|
||||
});
|
||||
|
||||
connection.boxed()
|
||||
Box::new(connection)
|
||||
}
|
||||
|
||||
pub fn authenticate(transport: Transport, credentials: Credentials, device_id: String)
|
||||
-> BoxFuture<(Transport, Credentials), io::Error>
|
||||
-> Box<Future<Item = (Transport, Credentials), Error = io::Error>>
|
||||
{
|
||||
use protocol::authentication::{APWelcome, ClientResponseEncrypted, CpuFamily, Os};
|
||||
|
||||
|
@ -50,7 +50,7 @@ pub fn authenticate(transport: Transport, credentials: Credentials, device_id: S
|
|||
let cmd = 0xab;
|
||||
let data = packet.write_to_bytes().unwrap();
|
||||
|
||||
transport.send((cmd, data)).and_then(|transport| {
|
||||
Box::new(transport.send((cmd, data)).and_then(|transport| {
|
||||
transport.into_future().map_err(|(err, _stream)| err)
|
||||
}).and_then(|(packet, transport)| {
|
||||
match packet {
|
||||
|
@ -71,5 +71,5 @@ pub fn authenticate(transport: Transport, credentials: Credentials, device_id: S
|
|||
Some((cmd, _)) => panic!("Unexpected packet {:?}", cmd),
|
||||
None => panic!("EOF"),
|
||||
}
|
||||
}).boxed()
|
||||
}))
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use byteorder::{BigEndian, ByteOrder};
|
||||
use futures::sync::{oneshot, mpsc};
|
||||
use futures::{Async, Poll, BoxFuture, Future};
|
||||
use futures::{Async, Poll, Future};
|
||||
use protobuf;
|
||||
use protocol;
|
||||
use std::collections::HashMap;
|
||||
|
@ -99,7 +99,7 @@ impl MercuryManager {
|
|||
}
|
||||
|
||||
pub fn subscribe<T: Into<String>>(&self, uri: T)
|
||||
-> BoxFuture<mpsc::UnboundedReceiver<MercuryResponse>, MercuryError>
|
||||
-> Box<Future<Item = mpsc::UnboundedReceiver<MercuryResponse>, Error = MercuryError>>
|
||||
{
|
||||
let uri = uri.into();
|
||||
let request = self.request(MercuryRequest {
|
||||
|
@ -110,7 +110,7 @@ impl MercuryManager {
|
|||
});
|
||||
|
||||
let manager = self.clone();
|
||||
request.map(move |response| {
|
||||
Box::new(request.map(move |response| {
|
||||
let (tx, rx) = mpsc::unbounded();
|
||||
|
||||
manager.lock(move |inner| {
|
||||
|
@ -133,7 +133,7 @@ impl MercuryManager {
|
|||
});
|
||||
|
||||
rx
|
||||
}).boxed()
|
||||
}))
|
||||
}
|
||||
|
||||
pub fn dispatch(&self, cmd: u8, mut data: EasyBuf) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crypto::digest::Digest;
|
||||
use crypto::sha1::Sha1;
|
||||
use futures::sync::mpsc;
|
||||
use futures::{Future, Stream, BoxFuture, IntoFuture, Poll, Async};
|
||||
use futures::{Future, Stream, IntoFuture, Poll, Async};
|
||||
use std::io;
|
||||
use std::sync::{RwLock, Arc, Weak};
|
||||
use tokio_core::io::EasyBuf;
|
||||
|
@ -90,7 +90,7 @@ impl Session {
|
|||
|
||||
fn create(handle: &Handle, transport: connection::Transport,
|
||||
config: SessionConfig, cache: Option<Cache>, username: String)
|
||||
-> (Session, BoxFuture<(), io::Error>)
|
||||
-> (Session, Box<Future<Item = (), Error = io::Error>>)
|
||||
{
|
||||
let (sink, stream) = transport.split();
|
||||
|
||||
|
@ -124,8 +124,8 @@ impl Session {
|
|||
.forward(sink).map(|_| ());
|
||||
let receiver_task = DispatchTask(stream, session.weak());
|
||||
|
||||
let task = (receiver_task, sender_task).into_future()
|
||||
.map(|((), ())| ()).boxed();
|
||||
let task = Box::new((receiver_task, sender_task).into_future()
|
||||
.map(|((), ())| ()));
|
||||
|
||||
(session, task)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue