mirror of
https://github.com/actix/actix-extras.git
synced 2025-07-01 20:25:09 +02:00
migrate to actix-service 0.2
This commit is contained in:
@ -26,7 +26,7 @@ pub type DefaultClient = Client<DefaultConnector>;
|
||||
/// WebSocket's client
|
||||
pub struct Client<T>
|
||||
where
|
||||
T: Service<TcpConnect, Error = ConnectorError>,
|
||||
T: Service<Request = TcpConnect, Error = ConnectorError>,
|
||||
T::Response: AsyncRead + AsyncWrite,
|
||||
{
|
||||
connector: T,
|
||||
@ -34,7 +34,7 @@ where
|
||||
|
||||
impl<T> Client<T>
|
||||
where
|
||||
T: Service<TcpConnect, Error = ConnectorError>,
|
||||
T: Service<Request = TcpConnect, Error = ConnectorError>,
|
||||
T::Response: AsyncRead + AsyncWrite,
|
||||
{
|
||||
/// Create new websocket's client factory
|
||||
@ -51,7 +51,7 @@ impl Default for Client<DefaultConnector> {
|
||||
|
||||
impl<T> Clone for Client<T>
|
||||
where
|
||||
T: Service<TcpConnect, Error = ConnectorError> + Clone,
|
||||
T: Service<Request = TcpConnect, Error = ConnectorError> + Clone,
|
||||
T::Response: AsyncRead + AsyncWrite,
|
||||
{
|
||||
fn clone(&self) -> Self {
|
||||
@ -61,12 +61,13 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Service<Connect> for Client<T>
|
||||
impl<T> Service for Client<T>
|
||||
where
|
||||
T: Service<TcpConnect, Error = ConnectorError>,
|
||||
T: Service<Request = TcpConnect, Error = ConnectorError>,
|
||||
T::Response: AsyncRead + AsyncWrite + 'static,
|
||||
T::Future: 'static,
|
||||
{
|
||||
type Request = Connect;
|
||||
type Response = Framed<T::Response, Codec>;
|
||||
type Error = ClientError;
|
||||
type Future = Either<
|
||||
|
@ -117,7 +117,7 @@ impl Parser {
|
||||
// control frames must have length <= 125
|
||||
match opcode {
|
||||
OpCode::Ping | OpCode::Pong if length > 125 => {
|
||||
return Err(ProtocolError::InvalidLength(length))
|
||||
return Err(ProtocolError::InvalidLength(length));
|
||||
}
|
||||
OpCode::Close if length > 125 => {
|
||||
debug!("Received close frame with payload length exceeding 125. Morphing to protocol close frame.");
|
||||
|
@ -20,7 +20,8 @@ impl<T> Default for VerifyWebSockets<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> NewService<(Request, Framed<T, Codec>)> for VerifyWebSockets<T> {
|
||||
impl<T> NewService for VerifyWebSockets<T> {
|
||||
type Request = (Request, Framed<T, Codec>);
|
||||
type Response = (Request, Framed<T, Codec>);
|
||||
type Error = (HandshakeError, Framed<T, Codec>);
|
||||
type InitError = ();
|
||||
@ -32,7 +33,8 @@ impl<T> NewService<(Request, Framed<T, Codec>)> for VerifyWebSockets<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Service<(Request, Framed<T, Codec>)> for VerifyWebSockets<T> {
|
||||
impl<T> Service for VerifyWebSockets<T> {
|
||||
type Request = (Request, Framed<T, Codec>);
|
||||
type Response = (Request, Framed<T, Codec>);
|
||||
type Error = (HandshakeError, Framed<T, Codec>);
|
||||
type Future = FutureResult<Self::Response, Self::Error>;
|
||||
|
@ -7,7 +7,7 @@ use super::{Codec, Frame, Message};
|
||||
|
||||
pub struct Transport<S, T>
|
||||
where
|
||||
S: Service<Frame, Response = Message> + 'static,
|
||||
S: Service<Request = Frame, Response = Message> + 'static,
|
||||
T: AsyncRead + AsyncWrite,
|
||||
{
|
||||
inner: FramedTransport<S, T, Codec>,
|
||||
@ -16,17 +16,17 @@ where
|
||||
impl<S, T> Transport<S, T>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite,
|
||||
S: Service<Frame, Response = Message>,
|
||||
S: Service<Request = Frame, Response = Message>,
|
||||
S::Future: 'static,
|
||||
S::Error: 'static,
|
||||
{
|
||||
pub fn new<F: IntoService<S, Frame>>(io: T, service: F) -> Self {
|
||||
pub fn new<F: IntoService<S>>(io: T, service: F) -> Self {
|
||||
Transport {
|
||||
inner: FramedTransport::new(Framed::new(io, Codec::new()), service),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with<F: IntoService<S, Frame>>(framed: Framed<T, Codec>, service: F) -> Self {
|
||||
pub fn with<F: IntoService<S>>(framed: Framed<T, Codec>, service: F) -> Self {
|
||||
Transport {
|
||||
inner: FramedTransport::new(framed, service),
|
||||
}
|
||||
@ -36,7 +36,7 @@ where
|
||||
impl<S, T> Future for Transport<S, T>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite,
|
||||
S: Service<Frame, Response = Message>,
|
||||
S: Service<Request = Frame, Response = Message>,
|
||||
S::Future: 'static,
|
||||
S::Error: 'static,
|
||||
{
|
||||
|
Reference in New Issue
Block a user