matrix-sdk 0.19.1

A high level Matrix client-server library.
Documentation
// Copyright 2026 The Matrix.org Foundation C.I.C.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use tokio::sync::broadcast::{Receiver, Sender};

use super::super::TimelineVectorDiffs;

/// A small type to send updates in all channels.
#[derive(Clone)]
pub struct PinnedEventsCacheUpdateSender {
    thread_sender: Sender<TimelineVectorDiffs>,
}

impl PinnedEventsCacheUpdateSender {
    /// Create a new [`PinnedEventsCacheUpdateSender`].
    pub fn new() -> Self {
        Self { thread_sender: Sender::new(32) }
    }

    /// Send a [`TimelineVectorDiffs`].
    pub fn send(&self, thread_update: TimelineVectorDiffs) {
        let _ = self.thread_sender.send(thread_update);
    }

    /// Create a new [`Receiver`] of [`TimelineVectorDiffs`].
    pub(super) fn new_pinned_events_receiver(&self) -> Receiver<TimelineVectorDiffs> {
        self.thread_sender.subscribe()
    }
}