mirror of
https://github.com/chatmail/core.git
synced 2026-05-19 23:06:32 +03:00
api!: remove Stream implementation for EventEmitter
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -1189,7 +1189,6 @@ dependencies = [
|
|||||||
"parking_lot",
|
"parking_lot",
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"pgp",
|
"pgp",
|
||||||
"pin-project",
|
|
||||||
"pretty_assertions",
|
"pretty_assertions",
|
||||||
"pretty_env_logger",
|
"pretty_env_logger",
|
||||||
"proptest",
|
"proptest",
|
||||||
|
|||||||
@@ -72,7 +72,6 @@ once_cell = { workspace = true }
|
|||||||
percent-encoding = "2.3"
|
percent-encoding = "2.3"
|
||||||
parking_lot = "0.12"
|
parking_lot = "0.12"
|
||||||
pgp = { version = "0.11", default-features = false }
|
pgp = { version = "0.11", default-features = false }
|
||||||
pin-project = "1"
|
|
||||||
pretty_env_logger = { version = "0.5", optional = true }
|
pretty_env_logger = { version = "0.5", optional = true }
|
||||||
qrcodegen = "1.7.0"
|
qrcodegen = "1.7.0"
|
||||||
quick-xml = "0.31"
|
quick-xml = "0.31"
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
//! # Events specification.
|
//! # Events specification.
|
||||||
|
|
||||||
use async_channel::{self as channel, Receiver, Sender, TrySendError};
|
use async_channel::{self as channel, Receiver, Sender, TrySendError};
|
||||||
use pin_project::pin_project;
|
|
||||||
|
|
||||||
pub(crate) mod chatlist_events;
|
pub(crate) mod chatlist_events;
|
||||||
mod payload;
|
mod payload;
|
||||||
@@ -60,14 +59,10 @@ impl Events {
|
|||||||
/// created events emitted by the [`Context`] will only be delivered to one of the
|
/// created events emitted by the [`Context`] will only be delivered to one of the
|
||||||
/// `EventEmitter`s.
|
/// `EventEmitter`s.
|
||||||
///
|
///
|
||||||
/// The `EventEmitter` is also a [`Stream`], so a typical usage is in a `while let` loop.
|
|
||||||
///
|
|
||||||
/// [`Context`]: crate::context::Context
|
/// [`Context`]: crate::context::Context
|
||||||
/// [`Context::get_event_emitter`]: crate::context::Context::get_event_emitter
|
/// [`Context::get_event_emitter`]: crate::context::Context::get_event_emitter
|
||||||
/// [`Stream`]: futures::stream::Stream
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
#[pin_project]
|
pub struct EventEmitter(Receiver<Event>);
|
||||||
pub struct EventEmitter(#[pin] Receiver<Event>);
|
|
||||||
|
|
||||||
impl EventEmitter {
|
impl EventEmitter {
|
||||||
/// Async recv of an event. Return `None` if the `Sender` has been dropped.
|
/// Async recv of an event. Return `None` if the `Sender` has been dropped.
|
||||||
@@ -76,17 +71,6 @@ impl EventEmitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl futures::stream::Stream for EventEmitter {
|
|
||||||
type Item = Event;
|
|
||||||
|
|
||||||
fn poll_next(
|
|
||||||
self: std::pin::Pin<&mut Self>,
|
|
||||||
cx: &mut std::task::Context<'_>,
|
|
||||||
) -> std::task::Poll<Option<Self::Item>> {
|
|
||||||
self.project().0.poll_next(cx)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The event emitted by a [`Context`] from an [`EventEmitter`].
|
/// The event emitted by a [`Context`] from an [`EventEmitter`].
|
||||||
///
|
///
|
||||||
/// Events are documented on the C/FFI API in `deltachat.h` as `DC_EVENT_*` constants. The
|
/// Events are documented on the C/FFI API in `deltachat.h` as `DC_EVENT_*` constants. The
|
||||||
|
|||||||
Reference in New Issue
Block a user