Skip to content

Commit

Permalink
FMT fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
LJ authored and LJ committed Sep 24, 2024
1 parent b9a2d4a commit eaba6bc
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 23 deletions.
30 changes: 16 additions & 14 deletions src/api_client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,21 +234,9 @@ impl AuthenticatedCVR {
///
/// # Errors
///
/// If deserializing user agent fails.
#[cfg(feature = "http_client")]
pub fn downgrade(self) -> Result<UnauthenticatedCVR, ApiError> {
Ok(UnauthenticatedCVR {
http: UnauthenticatedCVR::http_client(&self.config.user_agent)?,
http_rate_limiter: self.http_rate_limiter,
config: self.config,
})
}

/// Creates a new authenticated CVR API client
/// If deserializing user agent fails.# Panics
///
/// # Errors
///
/// If deserializing user agent into a header fails
/// If there's an internal programming error, aka should never panic.ails
pub fn new(
config: ApiConfiguration, auth: impl Into<SavedLoginCredentials> + Send,
) -> Result<Self, ApiError> {
Expand Down Expand Up @@ -306,12 +294,19 @@ impl AuthenticatedCVR {
lock.is_some()
}

// Clippy seems to be wrong, or at least haven't been able to figure out how
// this could be cleaned up more...
#[allow(clippy::significant_drop_tightening)]
/// Sends a WS message to the CVR API.
///
/// # Errors
///
/// If something with the request failed,
/// or if the WS connection wasn't already open and creating it failed.
///
/// # Panics
///
/// If there's an internal programming error, aka should never panic.
#[cfg(feature = "ws_client")]
pub async fn send(
&self,
Expand All @@ -336,12 +331,19 @@ impl AuthenticatedCVR {
.send(requestable)
}

// Clippy seems to be wrong, or at least haven't been able to figure out how
// this could be cleaned up more...
#[allow(clippy::significant_drop_tightening)]
/// Listens to events from the WS connection
///
/// # Errors
///
/// If creating the client fails,
/// or if the WS connection wasn't already open and creating it failed.
///
/// # Panics
///
/// If there's an internal programming error, aka should never panic.
#[cfg(feature = "ws_client")]
pub async fn listen(&self) -> Result<ws::ReceiverContainer, ApiError> {
{
Expand Down
9 changes: 3 additions & 6 deletions src/api_client/ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub type ReceiverContainer =
pub struct Client {
receive: ReceiverContainer,
handle: JoinHandle<()>,
internal_client: ezsockets::Client<InternalClientExt>,
internal: ezsockets::Client<InternalClientExt>,
}

struct InternalClientExt {
Expand Down Expand Up @@ -92,7 +92,7 @@ impl Client {
internal_client.call(()).ok();

let ws_client = Self {
internal_client,
internal: internal_client,
handle,
receive: std::sync::Arc::new(tokio::sync::Mutex::new(
UnboundedReceiverStream::from(received_receiver),
Expand All @@ -115,10 +115,7 @@ impl Client {
data: requestable,
};
let data = serde_json::to_vec(&data)?;
self
.internal_client
.binary(data)
.map_err(|e| ApiError::WebSocket(Box::new(e)))?;
self.internal.binary(data).map_err(|e| ApiError::WebSocket(Box::new(e)))?;

Ok(())
}
Expand Down
4 changes: 2 additions & 2 deletions src/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub use categories::*;

/// Seems like a lot if not all of the API calls are wrapped
/// in a generic data/message struct.
#[cfg(any(feature = "http"))]
#[cfg(feature = "http")]
#[serde_as]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
Expand Down Expand Up @@ -122,7 +122,7 @@ impl<'de> serde::Deserialize<'de> for WsResponseData {
}
}

#[cfg(any(feature = "http"))]
#[cfg(feature = "http")]
#[serde_as]
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "camelCase")]
Expand Down
2 changes: 1 addition & 1 deletion src/query/users.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl std::fmt::Debug for SavedLoginCredentials {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("SavedLoginCredentials")
.field("username", &self.username)
.field("token", &"*****")
.field("access_key", &"*****")
.finish()
}
}
Expand Down

0 comments on commit eaba6bc

Please sign in to comment.