Skip to content

Commit

Permalink
feat: Expose ClientMut as public API (#362)
Browse files Browse the repository at this point in the history
  • Loading branch information
0x676e67 authored Jan 25, 2025
1 parent fde1ca1 commit 455cf51
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
21 changes: 12 additions & 9 deletions src/client/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1647,12 +1647,24 @@ impl_debug!(
}
);

/// A mutable reference to a `ClientRef`.
///
/// This struct provides methods to mutate the state of a `ClientRef`.
#[derive(Debug)]
pub struct ClientMut<'c> {
inner: &'c mut ClientRef,
}

impl<'c> ClientMut<'c> {
/// Retrieves a mutable reference to the headers for this client.
///
/// # Returns
///
/// A mutable reference to the `HeaderMap` containing the headers for this client.
pub fn headers(&mut self) -> &mut HeaderMap {
&mut self.inner.headers
}

/// Sets the base URL for this client.
///
/// # Arguments
Expand All @@ -1669,15 +1681,6 @@ impl<'c> ClientMut<'c> {
self
}

/// Retrieves a mutable reference to the headers for this client.
///
/// # Returns
///
/// A mutable reference to the `HeaderMap` containing the headers for this client.
pub fn headers(&mut self) -> &mut HeaderMap {
&mut self.inner.headers
}

/// Sets the headers order for this client.
///
/// # Arguments
Expand Down
2 changes: 1 addition & 1 deletion src/client/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub use self::body::Body;
pub use self::http::{Client, ClientBuilder};
pub use self::http::{Client, ClientBuilder, ClientMut};
pub use self::request::{Request, RequestBuilder};
pub use self::response::Response;
pub use self::upgrade::Upgraded;
Expand Down
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,9 @@ pub use self::client::multipart;
pub use self::client::websocket::{
CloseCode, Message, WebSocket, WebSocketRequestBuilder, WebSocketResponse,
};
pub use self::client::{Body, Client, ClientBuilder, Request, RequestBuilder, Response, Upgraded};
pub use self::client::{
Body, Client, ClientBuilder, ClientMut, Request, RequestBuilder, Response, Upgraded,
};
pub use self::imp::{Impersonate, ImpersonateBuilder, ImpersonateOS, ImpersonateSettings};
pub use self::proxy::{NoProxy, Proxy};
pub use self::tls::{
Expand Down

0 comments on commit 455cf51

Please sign in to comment.