Skip to content

Commit

Permalink
Merge pull request #323 from boxdot/main
Browse files Browse the repository at this point in the history
chore: fix clippy 1.81
  • Loading branch information
rubdos authored Sep 30, 2024
2 parents 9c77576 + bb5212a commit 2327c23
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
7 changes: 5 additions & 2 deletions libsignal-service-hyper/src/push_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,12 +532,15 @@ impl PushService for HyperPushService {
}

#[tracing::instrument(skip(self, value, file), fields(file = file.as_ref().map(|_| "")))]
async fn post_to_cdn0<'s, C: io::Read + Send + 's>(
async fn post_to_cdn0<'s, C>(
&mut self,
path: &str,
value: &[(&str, &str)],
file: Option<(&str, &'s mut C)>,
) -> Result<(), ServiceError> {
) -> Result<(), ServiceError>
where
C: io::Read + Send + 's,
{
let mut form = mpart_async::client::MultipartRequest::default();

// mpart-async has a peculiar ordering of the form items,
Expand Down
6 changes: 6 additions & 0 deletions libsignal-service/examples/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ impl ExampleStore {
}

#[async_trait::async_trait(?Send)]
#[allow(clippy::diverging_sub_expression)]
impl PreKeyStore for ExampleStore {
/// Look up the pre-key corresponding to `prekey_id`.
async fn get_pre_key(
Expand Down Expand Up @@ -44,6 +45,7 @@ impl PreKeyStore for ExampleStore {
}

#[async_trait::async_trait(?Send)]
#[allow(clippy::diverging_sub_expression)]
impl KyberPreKeyStore for ExampleStore {
/// Look up the signed kyber pre-key corresponding to `kyber_prekey_id`.
async fn get_kyber_pre_key(
Expand Down Expand Up @@ -73,6 +75,7 @@ impl KyberPreKeyStore for ExampleStore {
}

#[async_trait::async_trait(?Send)]
#[allow(clippy::diverging_sub_expression)]
impl SignedPreKeyStore for ExampleStore {
/// Look up the signed pre-key corresponding to `signed_prekey_id`.
async fn get_signed_pre_key(
Expand All @@ -93,6 +96,7 @@ impl SignedPreKeyStore for ExampleStore {
}

#[async_trait::async_trait(?Send)]
#[allow(clippy::diverging_sub_expression)]
impl KyberPreKeyStoreExt for ExampleStore {
async fn store_last_resort_kyber_pre_key(
&mut self,
Expand Down Expand Up @@ -134,6 +138,7 @@ impl KyberPreKeyStoreExt for ExampleStore {
}

#[async_trait::async_trait(?Send)]
#[allow(clippy::diverging_sub_expression)]
impl IdentityKeyStore for ExampleStore {
/// Return the single specific identity the store is assumed to represent, with private key.
async fn get_identity_key_pair(
Expand Down Expand Up @@ -189,6 +194,7 @@ impl IdentityKeyStore for ExampleStore {
}

#[async_trait::async_trait(?Send)]
#[allow(clippy::diverging_sub_expression)]
impl PreKeysStore for ExampleStore {
/// ID of the next pre key
async fn next_pre_key_id(&self) -> Result<u32, SignalProtocolError> {
Expand Down
3 changes: 2 additions & 1 deletion libsignal-service/src/messagepipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,13 @@ impl MessagePipe {
/// WebSocketService that panics on every request, mainly for example code.
pub struct PanicingWebSocketService;

#[allow(clippy::diverging_sub_expression)]
#[cfg_attr(feature = "unsend-futures", async_trait::async_trait(?Send))]
#[cfg_attr(not(feature = "unsend-futures"), async_trait::async_trait)]
impl WebSocketService for PanicingWebSocketService {
type Stream = futures::channel::mpsc::Receiver<WebSocketStreamItem>;

async fn send_message(&mut self, _msg: Bytes) -> Result<(), ServiceError> {
unimplemented!();
todo!();
}
}
21 changes: 15 additions & 6 deletions libsignal-service/src/push_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -700,12 +700,14 @@ pub trait PushService: MaybeSend {
/// Upload larger file to CDN0 in legacy fashion, e.g. for attachments.
///
/// Implementations are allowed to *panic* when the Read instance throws an IO-Error
async fn post_to_cdn0<'s, C: std::io::Read + Send + 's>(
async fn post_to_cdn0<'s, C>(
&mut self,
path: &str,
value: &[(&str, &str)],
file: Option<(&str, &'s mut C)>,
) -> Result<(), ServiceError>;
) -> Result<(), ServiceError>
where
C: std::io::Read + Send + 's;

async fn ws(
&mut self,
Expand Down Expand Up @@ -851,11 +853,14 @@ pub trait PushService: MaybeSend {
/// Upload attachment to CDN
///
/// Returns attachment ID and the attachment digest
async fn upload_attachment<'s, C: std::io::Read + Send + 's>(
async fn upload_attachment<'s, C>(
&mut self,
attrs: &AttachmentV2UploadAttributes,
content: &'s mut C,
) -> Result<(u64, Vec<u8>), ServiceError> {
) -> Result<(u64, Vec<u8>), ServiceError>
where
C: std::io::Read + Send + 's,
{
let values = [
("acl", &attrs.acl as &str),
("key", &attrs.key),
Expand Down Expand Up @@ -1081,15 +1086,19 @@ pub trait PushService: MaybeSend {
/// See [`AccountManager`][struct@crate::AccountManager] for a convenience method.
///
/// Java equivalent: `writeProfile`
async fn write_profile<'s, C: std::io::Read + Send + 's, S: AsRef<str>>(
async fn write_profile<'s, C, S>(
&mut self,
version: &ProfileKeyVersion,
name: &[u8],
about: &[u8],
emoji: &[u8],
commitment: &ProfileKeyCommitment,
avatar: AvatarWrite<&mut C>,
) -> Result<Option<String>, ServiceError> {
) -> Result<Option<String>, ServiceError>
where
C: std::io::Read + Send + 's,
S: AsRef<str>,
{
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
struct SignalServiceProfileWrite<'s> {
Expand Down

0 comments on commit 2327c23

Please sign in to comment.