pub struct HaProxyService<S, P = Tcp, V = Two> { /* private fields */ }Expand description
Service to encode and write the HaProxy Protocol as a client on the connected stream.
This connector should in most cases happen as the first thing after establishing the connection.
Implementations§
Source§impl<S> HaProxyService<S>
impl<S> HaProxyService<S>
Sourcepub fn tcp(inner: S) -> Self
pub fn tcp(inner: S) -> Self
Create a new HaProxyService for the TCP protocol (default).
This is in the PROXY spec referred to as:
- TCP4 (for IPv4, v1)
- TCP6 (for IPv6, v1)
- Stream (v2)
Sourcepub fn v1(self) -> HaProxyService<S, Tcp, One>
pub fn v1(self) -> HaProxyService<S, Tcp, One>
Use version one of PROXY protocol, instead of the default version two.
Version one makes use of a less advanced text protocol, instead the more advanced binary v2 protocol.
Use this only if you have no control over a v1-only server.
Source§impl<S> HaProxyService<S, Udp>
impl<S> HaProxyService<S, Udp>
Sourcepub fn udp(inner: S) -> Self
pub fn udp(inner: S) -> Self
Create a new HaProxyService for the UDP protocol,
instead of the default TCP protocol.
This is in the PROXY spec referred to as:
- Datagram (v2)
Source§impl<S, P> HaProxyService<S, P>
impl<S, P> HaProxyService<S, P>
Sourcepub fn with_payload(self, payload: impl Into<Bytes>) -> Self
pub fn with_payload(self, payload: impl Into<Bytes>) -> Self
Attach a custom bytes payload to the PROXY header.
NOTE this is only possible in Version two of the PROXY Protocol.
In case you downgrade this HaProxyLayer to version one later
using Self::v1 this payload will be dropped.
Sourcepub fn set_payload(&mut self, payload: impl Into<Bytes>) -> &mut Self
pub fn set_payload(&mut self, payload: impl Into<Bytes>) -> &mut Self
Attach a custom bytes payload to the PROXY header.
NOTE this is only possible in Version two of the PROXY Protocol.
In case you downgrade this HaProxyLayer to version one later
using Self::v1 this payload will be dropped.
Sourcepub fn with_tlv(self, kind: Type, value: impl Into<Bytes>) -> Self
pub fn with_tlv(self, kind: Type, value: impl Into<Bytes>) -> Self
Attach a Type-Length-Value entry to the emitted v2 header.
See HaProxyLayer::with_tlv for details.
Sourcepub fn set_tlv(&mut self, kind: Type, value: impl Into<Bytes>) -> &mut Self
pub fn set_tlv(&mut self, kind: Type, value: impl Into<Bytes>) -> &mut Self
Attach a Type-Length-Value entry to the emitted v2 header.
See HaProxyLayer::with_tlv for details.
Sourcepub fn with_crc32c(self, enabled: bool) -> Self
pub fn with_crc32c(self, enabled: bool) -> Self
Toggle automatic emission of a valid PP2_TYPE_CRC32C TLV.
See [HaProxyLayer::crc32c] for details.
Sourcepub fn set_crc32c(&mut self, enabled: bool) -> &mut Self
pub fn set_crc32c(&mut self, enabled: bool) -> &mut Self
Toggle automatic emission of a valid PP2_TYPE_CRC32C TLV.
See [HaProxyLayer::crc32c] for details.
Trait Implementations§
Source§impl<S, P, Input> Service<Input> for HaProxyService<S, P, One>where
S: ConnectorService<Input, Connection: Io + Socket + Unpin>,
P: Send + 'static,
Input: Send + ExtensionsRef + 'static,
impl<S, P, Input> Service<Input> for HaProxyService<S, P, One>where
S: ConnectorService<Input, Connection: Io + Socket + Unpin>,
P: Send + 'static,
Input: Send + ExtensionsRef + 'static,
Source§type Output = EstablishedClientConnection<<S as ConnectorService<Input>>::Connection, Input>
type Output = EstablishedClientConnection<<S as ConnectorService<Input>>::Connection, Input>
Source§impl<S, P, Input> Service<Input> for HaProxyService<S, P, Two>where
S: ConnectorService<Input, Connection: Io + Socket + Unpin>,
P: Protocol + Send + 'static,
Input: Send + ExtensionsRef + 'static,
impl<S, P, Input> Service<Input> for HaProxyService<S, P, Two>where
S: ConnectorService<Input, Connection: Io + Socket + Unpin>,
P: Protocol + Send + 'static,
Input: Send + ExtensionsRef + 'static,
Source§type Output = EstablishedClientConnection<<S as ConnectorService<Input>>::Connection, Input>
type Output = EstablishedClientConnection<<S as ConnectorService<Input>>::Connection, Input>
Auto Trait Implementations§
impl<S, P, V> Freeze for HaProxyService<S, P, V>
impl<S, P, V> RefUnwindSafe for HaProxyService<S, P, V>where
S: RefUnwindSafe,
V: RefUnwindSafe,
impl<S, P, V> Send for HaProxyService<S, P, V>
impl<S, P, V> Sync for HaProxyService<S, P, V>
impl<S, P, V> Unpin for HaProxyService<S, P, V>
impl<S, P, V> UnsafeUnpin for HaProxyService<S, P, V>where
S: UnsafeUnpin,
V: UnsafeUnpin,
impl<S, P, V> UnwindSafe for HaProxyService<S, P, V>where
S: UnwindSafe,
V: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<S, Input, Connection> ConnectorService<Input> for S
impl<S, Input, Connection> ConnectorService<Input> for S
Source§type Connection = Connection
type Connection = Connection
ConnectorServiceSource§type Error = <S as Service<Input>>::Error
type Error = <S as Service<Input>>::Error
Source§fn connect(
&self,
input: Input,
) -> impl Future<Output = Result<EstablishedClientConnection<<S as ConnectorService<Input>>::Connection, Input>, <S as ConnectorService<Input>>::Error>> + Send
fn connect( &self, input: Input, ) -> impl Future<Output = Result<EstablishedClientConnection<<S as ConnectorService<Input>>::Connection, Input>, <S as ConnectorService<Input>>::Error>> + Send
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more