Commit ef6b74a150

ef6b74a150a67a65acf210bc9dfe40dc890c7357

parent: de3d9101bc

Unsigned

Darafei Praliaskouski <me@komzpa.net> · 2026-07-08 10:41 UTC
committer: <strk@kbt.io>

fix: clean up Rust 1.96 warnings

Layout: unified · split

src/render.rs +3 −51
@@ -1,9 +1,7 @@
11use url::Url;
22
33use matrix_sdk::{
4 encryption::verification::{
5 SasVerification, Verification, VerificationRequest,
6 },
4 encryption::verification::{SasVerification, Verification},
75 ruma::{
86 events::{
97 key::verification::{
@@ -644,7 +642,7 @@ render_start_content!(ToDeviceKeyVerificationStartEventContent);
644642
645643pub enum VerificationContext {
646644 Room(WeechatRoomMember, WeechatRoomMember),
647 ToDevice(VerificationRequest),
645 ToDevice,
648646}
649647
650648macro_rules! render_request_content {
@@ -670,7 +668,7 @@ macro_rules! render_request_content {
670668 )
671669 }
672670 }
673 VerificationContext::ToDevice(_) => {
671 VerificationContext::ToDevice => {
674672 format!("You have requested this device to be verified")
675673 }
676674 };
@@ -769,42 +767,9 @@ macro_rules! render_key_content {
769767render_key_content!(KeyVerificationKeyEventContent);
770768render_key_content!(ToDeviceKeyVerificationKeyEventContent);
771769
772/// Trait for message event types that contain an optional formatted body.
773/// `resolve_body` will return the formatted body if present, else fallback to
774/// the regular body.
775trait HasFormattedBody {
776 fn body(&self) -> &str;
777 fn formatted_body(&self) -> Option<&str>;
778 #[inline]
779 fn resolve_body(&self) -> &str {
780 self.formatted_body().unwrap_or_else(|| self.body())
781 }
782}
783
784// Repeating this for each event type would get boring fast so lets use a simple
785// macro to implement the trait for a struct that has a `body` and
786// `formatted_body` field
787macro_rules! has_formatted_body {
788 ($content: ident) => {
789 impl HasFormattedBody for $content {
790 #[inline]
791 fn body(&self) -> &str {
792 &self.body
793 }
794
795 #[inline]
796 fn formatted_body(&self) -> Option<&str> {
797 self.formatted.as_ref().map(|f| f.body.as_ref())
798 }
799 }
800 };
801}
802
803770/// This trait is implemented for message types that can contain either an URL
804771/// or an encrypted file. One of these _must_ be present.
805772pub trait HasUrlOrFile {
806 fn url(&self) -> Option<&MxcUri>;
807
808773 fn body(&self) -> &str;
809774
810775 #[inline]
@@ -829,14 +794,6 @@ macro_rules! has_url_or_file {
829794 &self.body
830795 }
831796
832 #[inline]
833 fn url(&self) -> Option<&MxcUri> {
834 match &self.source {
835 MediaSource::Plain(url) => Some(url),
836 _ => None,
837 }
838 }
839
840797 fn source(&self) -> &MediaSource {
841798 &self.source
842799 }
@@ -851,11 +808,6 @@ macro_rules! has_url_or_file {
851808 };
852809}
853810
854// this actually implements the trait for different event types
855has_formatted_body!(EmoteMessageEventContent);
856has_formatted_body!(NoticeMessageEventContent);
857has_formatted_body!(TextMessageEventContent);
858
859811has_url_or_file!(AudioMessageEventContent);
860812has_url_or_file!(FileMessageEventContent);
861813has_url_or_file!(ImageMessageEventContent);
src/room/members.rs −4
@@ -242,10 +242,6 @@ impl Members {
242242 }
243243 }
244244
245 fn room(&self) -> &Room {
246 &self.room
247 }
248
249245 pub fn mark_active(
250246 &self,
251247 user_id: &UserId,
src/room/verification.rs +3 −3
@@ -68,7 +68,7 @@ impl Verification {
6868 if let Some(ActiveVerification::Sas(verification)) =
6969 self.inner.borrow().clone()
7070 {
71 let ret =
71 let _ret =
7272 c.spawn(async move { verification.confirm().await }).await;
7373 }
7474 }
@@ -84,7 +84,7 @@ impl Verification {
8484 {
8585 let verification_clone = verification.clone();
8686
87 let ret = c
87 let _ret = c
8888 .spawn(async move {
8989 verification
9090 .accept_with_methods(vec![
@@ -158,7 +158,7 @@ impl Verification {
158158
159159 // We accept here automatically since the only method
160160 // we're supporting is SAS verification
161 let ret = connection
161 let _ret = connection
162162 .spawn(async move { sas.accept().await })
163163 .await;
164164 }
src/server.rs +2 −2
@@ -727,7 +727,7 @@ impl InnerServer {
727727 }
728728
729729 /// Borrow the server buffer handle.
730 pub fn server_buffer(&self) -> Ref<Option<BufferHandle>> {
730 pub fn server_buffer(&self) -> Ref<'_, Option<BufferHandle>> {
731731 self.server_buffer.borrow()
732732 }
733733
@@ -849,7 +849,7 @@ impl InnerServer {
849849 .cloned();
850850
851851 if let Some(mut buffer) = buffer {
852 buffer.update(sas).await;
852 let _ = buffer.update(sas).await;
853853 buffer.handle_event(&event).await;
854854 } else {
855855 let buffer = VerificationBuffer::new(
src/verification_buffer.rs +5 −14
@@ -87,14 +87,6 @@ impl Verification {
8787 }
8888 }
8989
90 async fn generate_qr_code(&self) -> Option<QrVerification> {
91 match self {
92 Verification::Request(r) => r.generate_qr_code().await.unwrap(),
93 Verification::Sas(_) => None,
94 Verification::Qr(_) => None,
95 }
96 }
97
9890 async fn cancel(&self) -> Result<(), Error> {
9991 match self {
10092 Verification::Request(r) => r.cancel().await,
@@ -111,7 +103,7 @@ struct InnerVerificationBuffer {
111103}
112104
113105impl InnerVerificationBuffer {
114 fn print_done(&self, buffer: BufferHandle) {}
106 fn print_done(&self, _buffer: BufferHandle) {}
115107
116108 pub async fn accept(&self, buffer: BufferHandle) -> Result<(), Error> {
117109 if let Some(c) = self.connection.borrow().clone() {
@@ -227,7 +219,7 @@ impl BufferCloseCallback for InnerVerificationBuffer {
227219impl VerificationBuffer {
228220 pub fn new(
229221 server_name: &str,
230 sender: &UserId,
222 _sender: &UserId,
231223 verification: impl Into<Verification>,
232224 connection: Rc<RefCell<Option<Connection>>>,
233225 ) -> Self {
@@ -305,12 +297,11 @@ impl VerificationBuffer {
305297 pub async fn handle_event(&self, event: &AnyToDeviceEvent) {
306298 match event {
307299 AnyToDeviceEvent::KeyVerificationRequest(e) => {
308 if let Verification::Request(request) =
300 if let Verification::Request(_) =
309301 self.inner.verification.borrow().clone()
310302 {
311 let content = e
312 .content
313 .render(&VerificationContext::ToDevice(request));
303 let content =
304 e.content.render(&VerificationContext::ToDevice);
314305
315306 self.print(&content);
316307 }