Private
Public Access
1
0

fix all warnings

This commit is contained in:
2025-06-16 19:25:24 -07:00
parent 9d591dffc5
commit 75fe4d4608
8 changed files with 18 additions and 110 deletions

View File

@@ -86,19 +86,10 @@ impl From<tungstenite::Error> for Error {
}
trait AuthBuilder {
fn with_auth(self, token: &Option<JwtToken>) -> Self;
fn with_auth_string(self, token: &Option<String>) -> Self;
}
impl AuthBuilder for hyper::http::request::Builder {
fn with_auth(self, token: &Option<JwtToken>) -> Self {
if let Some(token) = &token {
self.header("Authorization", token.to_header_value())
} else {
self
}
}
fn with_auth_string(self, token: &Option<String>) -> Self {
if let Some(token) = &token {
self.header("Authorization", format!("Bearer: {}", token))
@@ -223,7 +214,7 @@ impl Stream for ResponseStream {
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
self.body
.poll_next_unpin(cx)
.map_err(|e| Error::HTTPError(e))
.map_err(Error::HTTPError)
}
}
@@ -310,7 +301,7 @@ impl<K: AuthenticationStore + Send + Sync> APIInterface for HTTPAPIClient<K> {
async fn fetch_attachment_data(
&mut self,
guid: &String,
guid: &str,
preview: bool,
) -> Result<ResponseStream, Self::Error> {
let endpoint = format!("attachment?guid={}&preview={}", guid, preview);
@@ -324,7 +315,7 @@ impl<K: AuthenticationStore + Send + Sync> APIInterface for HTTPAPIClient<K> {
&mut self,
mut data: tokio::io::BufReader<R>,
filename: &str,
size: u64,
_size: u64,
) -> Result<String, Self::Error>
where
R: tokio::io::AsyncRead + Unpin + Send + Sync + 'static,

View File

@@ -47,7 +47,7 @@ pub trait APIInterface {
// (GET) /attachment
async fn fetch_attachment_data(
&mut self,
guid: &String,
guid: &str,
preview: bool,
) -> Result<Self::ResponseStream, Self::Error>;

View File

@@ -62,7 +62,7 @@ impl OutgoingMessageBuilder {
pub fn build(self) -> OutgoingMessage {
OutgoingMessage {
guid: self.guid.unwrap_or_else(|| Uuid::new_v4()),
guid: self.guid.unwrap_or_else(Uuid::new_v4),
text: self.text.unwrap(),
conversation_id: self.conversation_id.unwrap(),
file_transfer_guids: self.file_transfer_guids.unwrap_or_default(),

View File

@@ -3,6 +3,7 @@ use super::message::Message;
use serde::Deserialize;
#[derive(Debug, Clone, Deserialize)]
#[derive(Default)]
pub struct UpdateItem {
#[serde(rename = "messageSequenceNumber")]
pub seq: u64,
@@ -17,13 +18,3 @@ pub struct UpdateItem {
pub pong: bool,
}
impl Default for UpdateItem {
fn default() -> Self {
Self {
seq: 0,
conversation: None,
message: None,
pong: false,
}
}
}

View File

@@ -6,7 +6,7 @@ use uuid::Uuid;
pub use crate::APIInterface;
use crate::{
api::event_socket::{EventSocket, SinkMessage},
api::event_socket::{EventSocket, SinkMessage, SocketEvent, SocketUpdate},
api::http_client::Credentials,
model::{
Conversation, ConversationID, Event, JwtToken, Message, MessageID, OutgoingMessage,
@@ -16,6 +16,7 @@ use crate::{
use bytes::Bytes;
use futures_util::stream::BoxStream;
use futures_util::Sink;
use futures_util::StreamExt;
pub struct TestClient {
@@ -52,21 +53,20 @@ impl TestEventSocket {
#[async_trait]
impl EventSocket for TestEventSocket {
type Error = TestError;
type EventStream = BoxStream<'static, Result<Event, TestError>>;
type UpdateStream = BoxStream<'static, Result<Vec<UpdateItem>, TestError>>;
type EventStream = BoxStream<'static, Result<SocketEvent, TestError>>;
type UpdateStream = BoxStream<'static, Result<SocketUpdate, TestError>>;
async fn events(self) -> Self::EventStream {
futures_util::stream::iter(self.events.into_iter().map(Ok)).boxed()
async fn events(self) -> (Self::EventStream, impl Sink<SinkMessage, Error = Self::Error>) {
(
futures_util::stream::iter(self.events.into_iter().map(Ok)).boxed(),
futures_util::sink::sink(),
)
}
async fn raw_updates(self) -> Self::UpdateStream {
let results: Vec<Result<Vec<UpdateItem>, TestError>> = vec![];
futures_util::stream::iter(results.into_iter()).boxed()
}
fn get_sink(&mut self) -> impl futures_util::Sink<SinkMessage> {
todo!("")
}
}
#[async_trait]
@@ -126,7 +126,7 @@ impl APIInterface for TestClient {
async fn fetch_attachment_data(
&mut self,
guid: &String,
guid: &str,
preview: bool,
) -> Result<Self::ResponseStream, Self::Error> {
Ok(futures_util::stream::iter(vec![Ok(Bytes::from_static(b"test"))]).boxed())