matrix_sdk/event_cache/caches/pinned_events/updates.rs
1// Copyright 2026 The Matrix.org Foundation C.I.C.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use tokio::sync::broadcast::{Receiver, Sender};
16
17use super::super::TimelineVectorDiffs;
18
19/// A small type to send updates in all channels.
20#[derive(Clone)]
21pub struct PinnedEventsCacheUpdateSender {
22 thread_sender: Sender<TimelineVectorDiffs>,
23}
24
25impl PinnedEventsCacheUpdateSender {
26 /// Create a new [`PinnedEventsCacheUpdateSender`].
27 pub fn new() -> Self {
28 Self { thread_sender: Sender::new(32) }
29 }
30
31 /// Send a [`TimelineVectorDiffs`].
32 pub fn send(&self, thread_update: TimelineVectorDiffs) {
33 let _ = self.thread_sender.send(thread_update);
34 }
35
36 /// Create a new [`Receiver`] of [`TimelineVectorDiffs`].
37 pub(super) fn new_pinned_events_receiver(&self) -> Receiver<TimelineVectorDiffs> {
38 self.thread_sender.subscribe()
39 }
40}