1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656
use std::{
io,
pin::Pin,
task::{Context, Poll},
};
use futures::stream::{FusedStream, Stream};
use crate::{
dds::{
adapters::no_key::DeserializerAdapter,
no_key::datasample::DataSample,
qos::{HasQoSPolicy, QosPolicies},
readcondition::ReadCondition,
result::ReadResult,
statusevents::DataReaderStatus,
with_key::{
datareader as datareader_with_key,
datasample::{DataSample as WithKeyDataSample, Sample},
DataReader as WithKeyDataReader, DataReaderEventStream as WithKeyDataReaderEventStream,
DataReaderStream as WithKeyDataReaderStream,
},
},
serialization::CDRDeserializerAdapter,
structure::entity::RTPSEntity,
StatusEvented, GUID,
};
use super::wrappers::{DAWrapper, NoKeyWrapper};
/// Simplified type for CDR encoding
pub type DataReaderCdr<D> = DataReader<D, CDRDeserializerAdapter<D>>;
// ----------------------------------------------------
// DataReader for NO_KEY data. Does not require "D: Keyed"
/// DDS DataReader for no key topics.
/// # Examples
///
/// ```
/// use serde::{Serialize, Deserialize};
/// use rustdds::*;
/// use rustdds::no_key::DataReader;
/// use rustdds::serialization::CDRDeserializerAdapter;
///
/// let domain_participant = DomainParticipant::new(0).unwrap();
/// let qos = QosPolicyBuilder::new().build();
/// let subscriber = domain_participant.create_subscriber(&qos).unwrap();
///
/// #[derive(Serialize, Deserialize)]
/// struct SomeType {}
///
/// // NoKey is important
/// let topic = domain_participant.create_topic("some_topic".to_string(), "SomeType".to_string(), &qos, TopicKind::NoKey).unwrap();
/// let data_reader = subscriber.create_datareader_no_key::<SomeType, CDRDeserializerAdapter<_>>(&topic, None);
/// ```
pub struct DataReader<D, DA: DeserializerAdapter<D> = CDRDeserializerAdapter<D>> {
keyed_datareader: datareader_with_key::DataReader<NoKeyWrapper<D>, DAWrapper<DA>>,
}
// TODO: rewrite DataSample so it can use current Keyed version (and send back
// datasamples instead of current data)
impl<D: 'static, DA> DataReader<D, DA>
where
DA: DeserializerAdapter<D>,
{
pub(crate) fn from_keyed(
keyed: datareader_with_key::DataReader<NoKeyWrapper<D>, DAWrapper<DA>>,
) -> Self {
Self {
keyed_datareader: keyed,
}
}
/// Reads amount of samples found with `max_samples` and `read_condition`
/// parameters.
///
/// # Arguments
///
/// * `max_samples` - Limits maximum amount of samples read
/// * `read_condition` - Limits results by condition
///
/// # Examples
///
/// ```
/// # use serde::{Serialize, Deserialize};
/// # use rustdds::*;
/// # use rustdds::serialization::CDRDeserializerAdapter;
///
/// # let domain_participant = DomainParticipant::new(0).unwrap();
/// # let qos = QosPolicyBuilder::new().build();
/// # let subscriber = domain_participant.create_subscriber(&qos).unwrap();
/// #
/// # // NoKey is important
/// # let topic = domain_participant.create_topic("some_topic".to_string(), "SomeType".to_string(), &qos, TopicKind::NoKey).unwrap();
/// #
/// # #[derive(Serialize, Deserialize)]
/// # struct SomeType {}
/// #
/// let mut data_reader = subscriber.create_datareader_no_key::<SomeType, CDRDeserializerAdapter<_>>(&topic, None).unwrap();
/// let data = data_reader.read(10, ReadCondition::not_read());
/// ```
pub fn read(
&mut self,
max_samples: usize,
read_condition: ReadCondition,
) -> ReadResult<Vec<DataSample<&D>>> {
let values: Vec<WithKeyDataSample<&NoKeyWrapper<D>>> =
self.keyed_datareader.read(max_samples, read_condition)?;
let mut result = Vec::with_capacity(values.len());
for ks in values {
if let Some(s) = DataSample::<D>::from_with_key_ref(ks) {
result.push(s);
}
}
Ok(result)
}
/// Takes amount of sample found with `max_samples` and `read_condition`
/// parameters.
///
/// # Arguments
///
/// * `max_samples` - Limits maximum amount of samples read
/// * `read_condition` - Limits results by condition
///
/// # Examples
///
/// ```
/// # use serde::{Serialize, Deserialize};
/// # use rustdds::*;
/// # use rustdds::no_key::DataReader;
/// # use rustdds::serialization::CDRDeserializerAdapter;
/// #
/// # let domain_participant = DomainParticipant::new(0).unwrap();
/// # let qos = QosPolicyBuilder::new().build();
/// # let subscriber = domain_participant.create_subscriber(&qos).unwrap();
/// #
/// # // NoKey is important
/// # let topic = domain_participant.create_topic("some_topic".to_string(), "SomeType".to_string(), &qos, TopicKind::NoKey).unwrap();
/// #
/// # #[derive(Serialize, Deserialize)]
/// # struct SomeType {}
/// #
/// let mut data_reader = subscriber.create_datareader_no_key::<SomeType, CDRDeserializerAdapter<_>>(&topic, None).unwrap();
/// let data = data_reader.take(10, ReadCondition::not_read());
/// ```
pub fn take(
&mut self,
max_samples: usize,
read_condition: ReadCondition,
) -> ReadResult<Vec<DataSample<D>>> {
let values: Vec<WithKeyDataSample<NoKeyWrapper<D>>> =
self.keyed_datareader.take(max_samples, read_condition)?;
let mut result = Vec::with_capacity(values.len());
for ks in values {
if let Some(s) = DataSample::<D>::from_with_key(ks) {
result.push(s);
}
}
Ok(result)
}
/// Reads next unread sample
///
/// # Examples
///
/// ```
/// # use serde::{Serialize, Deserialize};
/// # use rustdds::*;
/// # use rustdds::no_key::DataReader;
/// # use rustdds::serialization::CDRDeserializerAdapter;
/// #
/// # let domain_participant = DomainParticipant::new(0).unwrap();
/// # let qos = QosPolicyBuilder::new().build();
/// # let subscriber = domain_participant.create_subscriber(&qos).unwrap();
/// #
/// # // NoKey is important
/// # let topic = domain_participant.create_topic("some_topic".to_string(), "SomeType".to_string(), &qos, TopicKind::NoKey).unwrap();
/// #
/// # #[derive(Serialize, Deserialize)]
/// # struct SomeType {}
/// #
/// let mut data_reader = subscriber.create_datareader_no_key::<SomeType, CDRDeserializerAdapter<_>>(&topic, None).unwrap();
/// while let Ok(Some(data)) = data_reader.read_next_sample() {
/// // Do something
/// }
/// ```
pub fn read_next_sample(&mut self) -> ReadResult<Option<DataSample<&D>>> {
let mut ds = self.read(1, ReadCondition::not_read())?;
Ok(ds.pop())
}
/// Takes next unread sample
///
/// # Examples
///
/// ```
/// # use serde::{Serialize, Deserialize};
/// # use rustdds::*;
/// # use rustdds::no_key::DataReader;
/// # use rustdds::serialization::CDRDeserializerAdapter;
/// #
/// # let domain_participant = DomainParticipant::new(0).unwrap();
/// # let qos = QosPolicyBuilder::new().build();
/// # let subscriber = domain_participant.create_subscriber(&qos).unwrap();
/// #
/// # // NoKey is important
/// # let topic = domain_participant.create_topic("some_topic".to_string(), "SomeType".to_string(), &qos, TopicKind::NoKey).unwrap();
/// #
/// # #[derive(Serialize, Deserialize)]
/// # struct SomeType {}
/// #
/// let mut data_reader = subscriber.create_datareader_no_key::<SomeType, CDRDeserializerAdapter<_>>(&topic, None).unwrap();
/// while let Ok(Some(data)) = data_reader.take_next_sample() {
/// // Do something
/// }
/// ```
pub fn take_next_sample(&mut self) -> ReadResult<Option<DataSample<D>>> {
let mut ds = self.take(1, ReadCondition::not_read())?;
Ok(ds.pop())
}
// Iterator interface
/// Produces an iterator over the currently available NOT_READ samples.
/// Yields only payload data, not SampleInfo metadata
/// This is not called `iter()` because it takes a mutable reference to self.
///
/// # Examples
///
/// ```
/// # use serde::{Serialize, Deserialize};
/// # use rustdds::*;
/// # use rustdds::no_key::DataReader;
/// # use rustdds::serialization::CDRDeserializerAdapter;
/// #
/// # let domain_participant = DomainParticipant::new(0).unwrap();
/// # let qos = QosPolicyBuilder::new().build();
/// # let subscriber = domain_participant.create_subscriber(&qos).unwrap();
/// #
/// # // NoKey is important
/// # let topic = domain_participant.create_topic("some_topic".to_string(), "SomeType".to_string(), &qos, TopicKind::NoKey).unwrap();
/// #
/// # #[derive(Serialize, Deserialize)]
/// # struct SomeType {}
/// #
/// let mut data_reader = subscriber.create_datareader_no_key::<SomeType, CDRDeserializerAdapter<_>>(&topic, None).unwrap();
/// for data in data_reader.iterator() {
/// // Do something
/// }
/// ```
pub fn iterator(&mut self) -> ReadResult<impl Iterator<Item = &D>> {
// TODO: We could come up with a more efficient implementation than wrapping a
// read call
Ok(
self
.read(std::usize::MAX, ReadCondition::not_read())?
.into_iter()
.map(|ds| ds.value),
)
}
/// Produces an iterator over the samples filtered by given condition.
/// Yields only payload data, not SampleInfo metadata
///
/// # Examples
///
/// ```
/// # use serde::{Serialize, Deserialize};
/// # use rustdds::*;
/// # use rustdds::no_key::DataReader;
/// # use rustdds::serialization::CDRDeserializerAdapter;
/// #
/// # let domain_participant = DomainParticipant::new(0).unwrap();
/// # let qos = QosPolicyBuilder::new().build();
/// # let subscriber = domain_participant.create_subscriber(&qos).unwrap();
/// #
/// # // NoKey is important
/// # let topic = domain_participant.create_topic("some_topic".to_string(), "SomeType".to_string(), &qos, TopicKind::NoKey).unwrap();
/// #
/// # #[derive(Serialize, Deserialize)]
/// # struct SomeType {}
/// #
/// let mut data_reader = subscriber.create_datareader_no_key::<SomeType, CDRDeserializerAdapter<_>>(&topic, None).unwrap();
/// for data in data_reader.conditional_iterator(ReadCondition::any()) {
/// // Do something
/// }
/// ```
pub fn conditional_iterator(
&mut self,
read_condition: ReadCondition,
) -> ReadResult<impl Iterator<Item = &D>> {
// TODO: We could come up with a more efficient implementation than wrapping a
// read call
Ok(
self
.read(std::usize::MAX, read_condition)?
.into_iter()
.map(|ds| ds.value),
)
}
/// Produces an iterator over the currently available NOT_READ samples.
/// Yields only payload data, not SampleInfo metadata
/// Removes samples from `DataReader`.
/// <strong>Note!</strong> If the iterator is only partially consumed, all the
/// samples it could have provided are still removed from the `Datareader`.
///
/// # Examples
///
/// ```
/// # use serde::{Serialize, Deserialize};
/// # use rustdds::*;
/// # use rustdds::no_key::DataReader;
/// # use rustdds::serialization::CDRDeserializerAdapter;
/// #
/// # let domain_participant = DomainParticipant::new(0).unwrap();
/// # let qos = QosPolicyBuilder::new().build();
/// # let subscriber = domain_participant.create_subscriber(&qos).unwrap();
/// #
/// # // NoKey is important
/// # let topic = domain_participant.create_topic("some_topic".to_string(), "SomeType".to_string(), &qos, TopicKind::NoKey).unwrap();
/// #
/// # #[derive(Serialize, Deserialize)]
/// # struct SomeType {}
/// #
/// let mut data_reader = subscriber.create_datareader_no_key::<SomeType, CDRDeserializerAdapter<_>>(&topic, None).unwrap();
/// for data in data_reader.into_iterator() {
/// // Do something
/// }
/// ```
pub fn into_iterator(&mut self) -> ReadResult<impl Iterator<Item = D>> {
// TODO: We could come up with a more efficient implementation than wrapping a
// read call
Ok(
self
.take(std::usize::MAX, ReadCondition::not_read())?
.into_iter()
.map(|ds| ds.value),
)
}
/// Produces an iterator over the samples filtered by given condition.
/// Yields only payload data, not SampleInfo metadata
/// <strong>Note!</strong> If the iterator is only partially consumed, all the
/// samples it could have provided are still removed from the `Datareader`.
///
/// # Examples
///
/// ```
/// # use serde::{Serialize, Deserialize};
/// # use rustdds::*;
/// # use rustdds::no_key::DataReader;
/// # use rustdds::serialization::CDRDeserializerAdapter;
/// #
/// # let domain_participant = DomainParticipant::new(0).unwrap();
/// # let qos = QosPolicyBuilder::new().build();
/// # let subscriber = domain_participant.create_subscriber(&qos).unwrap();
/// #
/// # // NoKey is important
/// # let topic = domain_participant.create_topic("some_topic".to_string(), "SomeType".to_string(), &qos, TopicKind::NoKey).unwrap();
/// #
/// # #[derive(Serialize, Deserialize)]
/// # struct SomeType {}
/// #
/// let mut data_reader = subscriber.create_datareader_no_key::<SomeType, CDRDeserializerAdapter<_>>(&topic, None).unwrap();
/// for data in data_reader.into_conditional_iterator(ReadCondition::any()) {
/// // Do something
/// }
/// ```
pub fn into_conditional_iterator(
&mut self,
read_condition: ReadCondition,
) -> ReadResult<impl Iterator<Item = D>> {
// TODO: We could come up with a more efficient implementation than wrapping a
// read call
Ok(
self
.take(std::usize::MAX, read_condition)?
.into_iter()
.map(|ds| ds.value),
)
}
/*
/// Gets latest RequestedDeadlineMissed status
///
/// # Examples
///
/// ```
/// # use serde::{Serialize, Deserialize};
/// # use rustdds::*;
/// # use rustdds::no_key::DataReader;
/// # use rustdds::serialization::CDRDeserializerAdapter;
/// #
/// # let domain_participant = DomainParticipant::new(0).unwrap();
/// # let qos = QosPolicyBuilder::new().build();
/// # let subscriber = domain_participant.create_subscriber(&qos).unwrap();
/// #
/// # // NoKey is important
/// # let topic = domain_participant.create_topic("some_topic".to_string(), "SomeType".to_string(), &qos, TopicKind::NoKey).unwrap();
/// #
/// # #[derive(Serialize, Deserialize)]
/// # struct SomeType {}
/// #
/// let mut data_reader = subscriber.create_datareader_no_key::<SomeType, CDRDeserializerAdapter<_>>(topic, None).unwrap();
/// if let Ok(Some(status)) = data_reader.get_requested_deadline_missed_status() {
/// // Do something
/// }
/// ```
pub fn get_requested_deadline_missed_status(
&mut self,
) -> ReadResult<Option<RequestedDeadlineMissedStatus>> {
self.keyed_datareader.get_requested_deadline_missed_status()
}
*/
/// An async stream for reading the (bare) data samples
pub fn async_sample_stream(self) -> DataReaderStream<D, DA> {
DataReaderStream {
keyed_stream: self.keyed_datareader.async_sample_stream(),
}
}
}
/// WARNING! UNTESTED
// TODO: test
// This is not part of DDS spec. We implement mio mio_06::Evented so that the
// application can asynchronously poll DataReader(s).
impl<D, DA> mio_06::Evented for DataReader<D, DA>
where
DA: DeserializerAdapter<D>,
{
// We just delegate all the operations to notification_receiver, since it
// already implements mio_06::Evented
fn register(
&self,
poll: &mio_06::Poll,
token: mio_06::Token,
interest: mio_06::Ready,
opts: mio_06::PollOpt,
) -> io::Result<()> {
self.keyed_datareader.register(poll, token, interest, opts)
}
fn reregister(
&self,
poll: &mio_06::Poll,
token: mio_06::Token,
interest: mio_06::Ready,
opts: mio_06::PollOpt,
) -> io::Result<()> {
self
.keyed_datareader
.reregister(poll, token, interest, opts)
}
fn deregister(&self, poll: &mio_06::Poll) -> io::Result<()> {
self.keyed_datareader.deregister(poll)
}
}
/// WARNING! UNTESTED
// TODO: test
impl<D, DA> mio_08::event::Source for DataReader<D, DA>
where
DA: DeserializerAdapter<D>,
{
fn register(
&mut self,
registry: &mio_08::Registry,
token: mio_08::Token,
interests: mio_08::Interest,
) -> io::Result<()> {
// with_key::DataReader implements .register() for two traits, so need to
// use disambiguation syntax to call .register() here.
<WithKeyDataReader<NoKeyWrapper<D>, DAWrapper<DA>> as mio_08::event::Source>::register(
&mut self.keyed_datareader,
registry,
token,
interests,
)
}
fn reregister(
&mut self,
registry: &mio_08::Registry,
token: mio_08::Token,
interests: mio_08::Interest,
) -> io::Result<()> {
<WithKeyDataReader<NoKeyWrapper<D>, DAWrapper<DA>> as mio_08::event::Source>::reregister(
&mut self.keyed_datareader,
registry,
token,
interests,
)
}
fn deregister(&mut self, registry: &mio_08::Registry) -> io::Result<()> {
<WithKeyDataReader<NoKeyWrapper<D>, DAWrapper<DA>> as mio_08::event::Source>::deregister(
&mut self.keyed_datareader,
registry,
)
}
}
/// WARNING! UNTESTED
// TODO: test
use crate::with_key::SimpleDataReaderEventStream;
impl<'a, D, DA>
StatusEvented<
'a,
DataReaderStatus,
SimpleDataReaderEventStream<'a, NoKeyWrapper<D>, DAWrapper<DA>>,
> for DataReader<D, DA>
where
D: 'static,
DA: DeserializerAdapter<D>,
{
fn as_status_evented(&mut self) -> &dyn mio_06::Evented {
self.keyed_datareader.as_status_evented()
}
fn as_status_source(&mut self) -> &mut dyn mio_08::event::Source {
self.keyed_datareader.as_status_source()
}
fn as_async_status_stream(
&'a self,
) -> SimpleDataReaderEventStream<'a, NoKeyWrapper<D>, DAWrapper<DA>> {
self.keyed_datareader.as_async_status_stream()
}
fn try_recv_status(&self) -> Option<DataReaderStatus> {
self.keyed_datareader.try_recv_status()
}
}
impl<D, DA> HasQoSPolicy for DataReader<D, DA>
where
D: 'static,
DA: DeserializerAdapter<D>,
{
fn qos(&self) -> QosPolicies {
self.keyed_datareader.qos()
}
}
impl<D, DA> RTPSEntity for DataReader<D, DA>
where
D: 'static,
DA: DeserializerAdapter<D>,
{
fn guid(&self) -> GUID {
self.keyed_datareader.guid()
}
}
// ----------------------------------------------
// ----------------------------------------------
// Async interface for the DataReader
/// Wraps [`with_key::DataReaderStream`](crate::with_key::DataReaderStream) and
/// unwraps [`Sample`](crate::with_key::Sample) and `NoKeyWrapper` on
/// `poll_next`.
pub struct DataReaderStream<
D: 'static,
DA: DeserializerAdapter<D> + 'static = CDRDeserializerAdapter<D>,
> {
keyed_stream: WithKeyDataReaderStream<NoKeyWrapper<D>, DAWrapper<DA>>,
}
impl<D, DA> DataReaderStream<D, DA>
where
D: 'static,
DA: DeserializerAdapter<D>,
{
pub fn async_event_stream(&self) -> DataReaderEventStream<D, DA> {
DataReaderEventStream {
keyed_stream: self.keyed_stream.async_event_stream(),
}
}
}
// https://users.rust-lang.org/t/take-in-impl-future-cannot-borrow-data-in-a-dereference-of-pin/52042
impl<D, DA> Unpin for DataReaderStream<D, DA>
where
D: 'static,
DA: DeserializerAdapter<D>,
{
}
impl<D, DA> Stream for DataReaderStream<D, DA>
where
D: 'static,
DA: DeserializerAdapter<D>,
{
type Item = ReadResult<D>;
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
match Pin::new(&mut Pin::into_inner(self).keyed_stream).poll_next(cx) {
Poll::Ready(Some(Err(e))) => Poll::Ready(Some(Err(e))),
Poll::Ready(Some(Ok(Sample::Value(d)))) => Poll::Ready(Some(Ok(d.d))), /* Unwraps Sample and NoKeyWrapper */
// Disposed data is ignored
Poll::Ready(Some(Ok(Sample::Dispose(_)))) => Poll::Pending,
Poll::Ready(None) => Poll::Ready(None), // This should never happen
Poll::Pending => Poll::Pending,
}
}
}
impl<D, DA> FusedStream for DataReaderStream<D, DA>
where
D: 'static,
DA: DeserializerAdapter<D>,
{
fn is_terminated(&self) -> bool {
false // Never terminate. This means it is always valid to call poll_next().
}
}
// ----------------------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------------------
/// Wraps [`with_key::DataReaderEventStream`](crate::with_key::DataReaderEventStream).
pub struct DataReaderEventStream<
D: 'static,
DA: DeserializerAdapter<D> + 'static = CDRDeserializerAdapter<D>,
> {
keyed_stream: WithKeyDataReaderEventStream<NoKeyWrapper<D>, DAWrapper<DA>>,
}
impl<D, DA> Stream for DataReaderEventStream<D, DA>
where
D: 'static,
DA: DeserializerAdapter<D>,
{
type Item = DataReaderStatus;
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
Pin::new(&mut Pin::into_inner(self).keyed_stream).poll_next(cx)
}
}
impl<D, DA> FusedStream for DataReaderEventStream<D, DA>
where
D: 'static,
DA: DeserializerAdapter<D>,
{
fn is_terminated(&self) -> bool {
false // Never terminate. This means it is always valid to call poll_next().
}
}