fastcgi_client/
request.rs

1// Copyright 2022 jmjoy
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! FastCGI request structure and builders.
16//!
17//! This module provides the `Request` struct that encapsulates
18//! the parameters and stdin data for a FastCGI request.
19
20use crate::Params;
21use tokio::io::AsyncRead;
22
23/// FastCGI request containing parameters and stdin data.
24///
25/// This structure represents a complete FastCGI request with all necessary
26/// parameters and an optional stdin stream for request body data.
27pub struct Request<'a, I: AsyncRead + Unpin> {
28    pub(crate) params: Params<'a>,
29    pub(crate) stdin: I,
30}
31
32impl<'a, I: AsyncRead + Unpin> Request<'a, I> {
33    /// Creates a new FastCGI request with the given parameters and stdin.
34    ///
35    /// # Arguments
36    ///
37    /// * `params` - The FastCGI parameters
38    /// * `stdin` - The stdin stream for request body data
39    pub fn new(params: Params<'a>, stdin: I) -> Self {
40        Self { params, stdin }
41    }
42
43    /// Returns a reference to the request parameters.
44    pub fn params(&self) -> &Params<'a> {
45        &self.params
46    }
47
48    /// Returns a mutable reference to the request parameters.
49    pub fn params_mut(&mut self) -> &mut Params<'a> {
50        &mut self.params
51    }
52
53    /// Returns a reference to the stdin stream.
54    pub fn stdin(&self) -> &I {
55        &self.stdin
56    }
57
58    /// Returns a mutable reference to the stdin stream.
59    pub fn stdin_mut(&mut self) -> &mut I {
60        &mut self.stdin
61    }
62}