pub struct Client<S, M> { /* private fields */ }Expand description
Async client for handling communication between fastcgi server.
Implementations§
Source§impl<S> Client<TokioCompat<S>, ShortConn>
impl<S> Client<TokioCompat<S>, ShortConn>
Sourcepub fn new_tokio(stream: S) -> Self
Available on crate feature runtime-tokio only.
pub fn new_tokio(stream: S) -> Self
runtime-tokio only.Construct a Client Object with a Tokio stream under short connection
mode.
§Examples
use fastcgi_client::Client;
use tokio::net::TcpStream;
let tcp_stream = TcpStream::connect(("127.0.0.1", 9000)).await.unwrap();
let _tcp_client = Client::new_tokio(tcp_stream);
let unix_stream = UnixStream::connect("/run/php-fpm.sock").await.unwrap();
let _unix_client = Client::new_tokio(unix_stream);Source§impl<S> Client<S, ShortConn>
impl<S> Client<S, ShortConn>
Sourcepub fn new_smol(stream: S) -> Self
Available on crate feature runtime-smol only.
pub fn new_smol(stream: S) -> Self
runtime-smol only.Construct a Client Object with a Smol-compatible stream under short
connection mode.
§Examples
use fastcgi_client::Client;
use smol::net::TcpStream;
let tcp_stream = TcpStream::connect(("127.0.0.1", 9000)).await.unwrap();
let _tcp_client = Client::new_smol(tcp_stream);
let unix_stream = UnixStream::connect("/run/php-fpm.sock").await.unwrap();
let _unix_client = Client::new_smol(unix_stream);Source§impl<S: AsyncRead + AsyncWrite + Unpin> Client<S, ShortConn>
impl<S: AsyncRead + AsyncWrite + Unpin> Client<S, ShortConn>
Sourcepub async fn execute_once<I: AsyncRead + Unpin>(
self,
request: Request<'_, I>,
) -> ClientResult<Response>
pub async fn execute_once<I: AsyncRead + Unpin>( self, request: Request<'_, I>, ) -> ClientResult<Response>
Send request and receive response from fastcgi server, under short connection mode.
Sourcepub async fn execute_once_stream<I: AsyncRead + Unpin>(
self,
request: Request<'_, I>,
) -> ClientResult<ResponseStream<S>>
pub async fn execute_once_stream<I: AsyncRead + Unpin>( self, request: Request<'_, I>, ) -> ClientResult<ResponseStream<S>>
Send request and receive response stream from fastcgi server, under short connection mode.
§Examples
use fastcgi_client::{io, response::Content, Client, Params, Request, StreamExt};
use tokio::net::TcpStream;
let stream = TcpStream::connect(("127.0.0.1", 9000)).await.unwrap();
let client = Client::new_tokio(stream);
let mut stream = client
.execute_once_stream(Request::new(Params::default(), io::empty()))
.await
.unwrap();
while let Some(content) = stream.next().await {
let content = content.unwrap();
match content {
Content::Stdout(out) => todo!(),
Content::Stderr(out) => todo!(),
}
}
}Source§impl<S> Client<TokioCompat<S>, KeepAlive>
impl<S> Client<TokioCompat<S>, KeepAlive>
Sourcepub fn new_keep_alive_tokio(stream: S) -> Self
Available on crate feature runtime-tokio only.
pub fn new_keep_alive_tokio(stream: S) -> Self
runtime-tokio only.Construct a Client Object with a Tokio stream under keep-alive mode.
§Examples
use fastcgi_client::Client;
use tokio::net::TcpStream;
let tcp_stream = TcpStream::connect(("127.0.0.1", 9000)).await.unwrap();
let _tcp_client = Client::new_keep_alive_tokio(tcp_stream);
let unix_stream = UnixStream::connect("/run/php-fpm.sock").await.unwrap();
let _unix_client = Client::new_keep_alive_tokio(unix_stream);Source§impl<S> Client<S, KeepAlive>
impl<S> Client<S, KeepAlive>
Sourcepub fn new_keep_alive_smol(stream: S) -> Self
Available on crate feature runtime-smol only.
pub fn new_keep_alive_smol(stream: S) -> Self
runtime-smol only.Construct a Client Object with a Smol-compatible stream under
keep-alive mode.
§Examples
use fastcgi_client::Client;
use smol::net::TcpStream;
let tcp_stream = TcpStream::connect(("127.0.0.1", 9000)).await.unwrap();
let _tcp_client = Client::new_keep_alive_smol(tcp_stream);
let unix_stream = UnixStream::connect("/run/php-fpm.sock").await.unwrap();
let _unix_client = Client::new_keep_alive_smol(unix_stream);Source§impl<S: AsyncRead + AsyncWrite + Unpin> Client<S, KeepAlive>
impl<S: AsyncRead + AsyncWrite + Unpin> Client<S, KeepAlive>
Sourcepub async fn execute<I: AsyncRead + Unpin>(
&mut self,
request: Request<'_, I>,
) -> ClientResult<Response>
pub async fn execute<I: AsyncRead + Unpin>( &mut self, request: Request<'_, I>, ) -> ClientResult<Response>
Send request and receive response from fastcgi server, under keep alive connection mode.
Sourcepub async fn execute_stream<I: AsyncRead + Unpin>(
&mut self,
request: Request<'_, I>,
) -> ClientResult<ResponseStream<&mut S>>
pub async fn execute_stream<I: AsyncRead + Unpin>( &mut self, request: Request<'_, I>, ) -> ClientResult<ResponseStream<&mut S>>
Send request and receive response stream from fastcgi server, under keep alive connection mode.
§Examples
use fastcgi_client::{io, response::Content, Client, Params, Request, StreamExt};
use tokio::net::TcpStream;
let stream = TcpStream::connect(("127.0.0.1", 9000)).await.unwrap();
let mut client = Client::new_keep_alive_tokio(stream);
for _ in (0..3) {
let mut stream = client
.execute_stream(Request::new(Params::default(), io::empty()))
.await
.unwrap();
while let Some(content) = stream.next().await {
let content = content.unwrap();
match content {
Content::Stdout(out) => todo!(),
Content::Stderr(out) => todo!(),
}
}
}
}Auto Trait Implementations§
impl<S, M> Freeze for Client<S, M>where
S: Freeze,
impl<S, M> RefUnwindSafe for Client<S, M>where
S: RefUnwindSafe,
M: RefUnwindSafe,
impl<S, M> Send for Client<S, M>
impl<S, M> Sync for Client<S, M>
impl<S, M> Unpin for Client<S, M>
impl<S, M> UnsafeUnpin for Client<S, M>where
S: UnsafeUnpin,
impl<S, M> UnwindSafe for Client<S, M>where
S: UnwindSafe,
M: 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
Mutably borrows from an owned value. Read more