Skip to content

Commit

Permalink
feat: move trailers to the transfer module
Browse files Browse the repository at this point in the history
  • Loading branch information
OneOfOne committed Apr 7, 2024
2 parents 13bec83 + dca360e commit 21f7ffc
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
10 changes: 9 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,19 @@ pub use status::Status;
pub use status_code::StatusCode;
pub use version::Version;

#[doc(inline)]
pub use transfer::trailers::Trailers;

#[doc(inline)]
pub use mime::Mime;

#[doc(inline)]
pub use headers::Headers;

#[doc(inline)]
pub use crate::url::Url;

pub mod security;
pub mod trailers;

#[cfg(feature = "hyperium_http")]
mod hyperium_http;
Expand Down
5 changes: 3 additions & 2 deletions src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ use std::task::{Context, Poll};
use crate::convert::{DeserializeOwned, Serialize};
use crate::headers::{self, HeaderName, HeaderValue, HeaderValues, Headers, Names, ToHeaderValues, Values, CONTENT_TYPE};
use crate::mime::Mime;
use crate::trailers::{self, Trailers};

use crate::transfer::{trailers, Trailers};
use crate::{Body, Extensions, Method, Url, Version};

pin_project_lite::pin_project! {
Expand Down Expand Up @@ -532,7 +533,7 @@ impl Request {
self.version = version;
}

/// Sends trailers to the a receiver.
/// Sends trailers to the receiver.
pub fn send_trailers(&mut self) -> trailers::Sender {
self.has_trailers = true;
let sender = self.trailers_sender.take().expect("Trailers sender can only be constructed once");
Expand Down
2 changes: 1 addition & 1 deletion src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::task::{Context, Poll};
use crate::convert::DeserializeOwned;
use crate::headers::{self, HeaderName, HeaderValue, HeaderValues, Headers, Names, ToHeaderValues, Values, CONTENT_TYPE};
use crate::mime::Mime;
use crate::trailers::{self, Trailers};
use crate::transfer::{trailers, Trailers};
use crate::upgrade;
use crate::{Body, Extensions, StatusCode, Version};

Expand Down
2 changes: 2 additions & 0 deletions src/transfer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
mod encoding;
mod encoding_proposal;
mod te;
pub mod trailers;
mod transfer_encoding;

pub use encoding::Encoding;
pub use encoding_proposal::EncodingProposal;
pub use te::TE;
pub use trailers::Trailers;
pub use transfer_encoding::TransferEncoding;
6 changes: 3 additions & 3 deletions src/trailers.rs → src/transfer/trailers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
//! # async_std::task::block_on(async {
//! #
//! use http_types_rs::{Url, Method, Request};
//! use http_types_rs::trailers::Trailers;
//! use http_types_rs::transfer::Trailers;
//! use http_types_rs::headers::{HeaderName, HeaderValue};
//! use async_std::task;
//! use std::str::FromStr;
Expand Down Expand Up @@ -76,7 +76,7 @@ impl Trailers {
/// ```
/// # fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
/// #
/// use http_types_rs::trailers::Trailers;
/// use http_types_rs::transfer::Trailers;
///
/// let mut trailers = Trailers::new();
/// trailers.insert("Content-Type", "text/plain");
Expand All @@ -97,7 +97,7 @@ impl Trailers {
/// ```
/// # fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
/// #
/// use http_types_rs::trailers::Trailers;
/// use http_types_rs::transfer::Trailers;
///
/// let mut trailers = Trailers::new();
/// trailers.append("Content-Type", "text/plain");
Expand Down

0 comments on commit 21f7ffc

Please sign in to comment.