use classy::hl::{BodyState, HttpClientResponse, RequestBodyState, ResponseBodyState};
#[cfg(feature = "enable_stop_iteration")]
use classy::hl::{HeadersBodyState, RequestHeadersBodyState, ResponseHeadersBodyState};
pub trait PayloadBinding {
fn as_bytes(&self) -> Vec<u8>;
}
impl PayloadBinding for &[u8] {
fn as_bytes(&self) -> Vec<u8> {
self.to_vec()
}
}
impl PayloadBinding for String {
fn as_bytes(&self) -> Vec<u8> {
self.as_bytes().to_vec()
}
}
impl PayloadBinding for RequestBodyState {
fn as_bytes(&self) -> Vec<u8> {
self.handler().body()
}
}
#[cfg(feature = "enable_stop_iteration")]
impl PayloadBinding for RequestHeadersBodyState {
fn as_bytes(&self) -> Vec<u8> {
self.handler().body()
}
}
impl PayloadBinding for ResponseBodyState {
fn as_bytes(&self) -> Vec<u8> {
self.handler().body()
}
}
#[cfg(feature = "enable_stop_iteration")]
impl PayloadBinding for ResponseHeadersBodyState {
fn as_bytes(&self) -> Vec<u8> {
self.handler().body()
}
}
impl PayloadBinding for HttpClientResponse {
fn as_bytes(&self) -> Vec<u8> {
self.body().to_vec()
}
}