pub fn poll<T>(&mut self, subscriber_id: &SubscriberId) -> Result<VecDeque<T>, EventError>
    where
        T: DeserializeOwned, {
        if self.subscribers.contains_key(subscriber_id) {
            let (topic_name, poll_configuration, cursor) = self
                .subscribers
                .get_mut(subscriber_id)
                .expect("A topic is missing, but is identified as existing");
            let topic = self
                .topics
                .get(topic_name)
                .expect("A subscriber Id has been linked to a non existing topic");

            let slice_start = *cursor;
            let slice_end = if topic.messages.len() - *cursor < poll_configuration.max_messages {
                topic.messages.len()
            } else {
                *cursor + poll_configuration.max_messages
            };
            let target_slice = &topic.messages[slice_start..slice_end];
            let polled: VecDeque<T> =
                target_slice.iter().filter_map(|message| from_str(message).ok()).collect();
            *cursor += polled.len();
            return Ok(polled);
        }
        Err(EventError::SubscriberIdDoesNotExist)
    }
/// Retrieves a list of events using `subscriber_id` subscription to a topic
Retrieves a list of events using `subscriber_id` subscription to a topic
Retrieves a list of events using ` subscriber_id ` subscription to a topic
pub fn poll<T>(&mut self, subscriber_id: &SubscriberId) -> Result<VecDeque<T>, EventError>
    where
        T: DeserializeOwned, {
        if self.subscribers.contains_key(subscriber_id) {
            let (topic_name, poll_configuration, cursor) = self
                .subscribers
                .get_mut(subscriber_id)
                .expect("A topic is missing, but is identified as existing");
            let topic = self
                .topics
                .get(topic_name)
                .expect("A subscriber Id has been linked to a non existing topic");
            let slice_start = *cursor;
            let slice_end = if topic.messages.len() - *cursor < poll_configuration.max_messages {
                topic.messages.len()
            } else {
                *cursor + poll_configuration.max_messages
            };
            let target_slice = &topic.messages[slice_start..slice_end];
            let polled: VecDeque<T> =
                target_slice.iter().filter_map(|message| from_str(message).ok()).collect();
            *cursor += polled.len();
            return Ok(polled);
        }
        Err(EventError::SubscriberIdDoesNotExist)
    }
pub fn poll < T > ( & mut self , subscriber_id : & SubscriberId ) -> Result < VecDeque < T > , EventError > where T : DeserializeOwned , { if self . subscribers . contains_key ( subscriber_id ) { let ( topic_name , poll_configuration , cursor ) = self . subscribers . get_mut ( subscriber_id ) . expect ( " " ) ; let topic = self . topics . get ( topic_name ) . expect ( " " ) ; let slice_start = * cursor ; let slice_end = if topic . messages . len ( ) - * cursor < poll_configuration . max_messages { topic . messages . len ( ) } else { * cursor + poll_configuration . max_messages } ; let target_slice = & topic . messages [ slice_start .. slice_end ] ; let polled : VecDeque < T > = target_slice . iter ( ) . filter_map ( | message | from_str ( message ) . ok ( ) ) . collect ( ) ; * cursor += polled . len ( ) ; return Ok ( polled ) ; } Err ( EventError :: SubscriberIdDoesNotExist ) }
Retrieves a list of events using `subscriber_id` subscription to a topic
Retrieves a list of events using ` subscriber_id ` subscription to a topic
&mut self
subscriber_id
&SubscriberId
&mut self
subscriber_id
&SubscriberId