Struct tokio_fastcgi::Requests

source ·
pub struct Requests<R: AsyncRead + Unpin + Send, W: AsyncWrite + Unpin + Send> { /* private fields */ }
Expand description

Processes records form an input and output stream.

FastCGI allow multiple requests to be interleaved within one data-stream. This struct reads the FastCGI-records from an input stream and assembles them into a Request.

Beware: Requests are built in memory. Having huge requests can eat up all of your systems memory.

Implementations§

source§

impl<'w, R: AsyncRead + Unpin + Send, W: AsyncWrite + Unpin + Send> Requests<R, W>

source

pub fn new(rd: R, wr: W, max_conns: u8, max_reqs: u8) -> Self

Creates a new Requests instance.

As soon as a new connection is accepted the read and write parts of this connection should be passed to this function. It will create a new Requests instance that will handle the communication between the web-server and the FastCGI application.

In addition to the read and write side of the connection two more parameters must be passed:

  • max_conns
    Maximum number of concurrent connections. This value will be returned to the web-server to allow it to adjust its connection handling.
  • max_reqs
    Maximum number of concurrent requests. Concurrent requests are handled by tokio-fastcgi but they consume memory. This value is used to tell the web-server how many concurrent requests he can use per connection.
source

pub fn from_split_socket( split_socket: (R, W), max_conns: u8, max_reqs: u8 ) -> Self

Same as new but takes a tuple containing the read and write side of the socket instead of two distinct variables

This is more convenient in combination with the split function.

§Example
if let Ok(mut socket) = listener.accept().await {
  tokio::spawn(async move {
  // Directly use the result of the split() call to construct a Requests instance
    let mut requests = Requests::from_split_socket(socket.0.split(), 10, 10);

    // Process the requests
  });
}
source

pub async fn next(&mut self) -> Result<Option<Request<W>>, Error>

Fetches the next request from this connection

This function asynchronously fetches FastCGI records and assembles them into requests. It does the de-interlacing to allow multiple requests to be processed in parallel. As soon as the information for a request is complete, it returns a Request instance for further processing.

This function will do the book keeping and process system requests like FCGI_GET_VALUES or FCGI_ABORT_REQUEST.

Auto Trait Implementations§

§

impl<R, W> !RefUnwindSafe for Requests<R, W>

§

impl<R, W> Send for Requests<R, W>

§

impl<R, W> Sync for Requests<R, W>
where R: Sync,

§

impl<R, W> Unpin for Requests<R, W>

§

impl<R, W> !UnwindSafe for Requests<R, W>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.