fn filtered_events(&self, final_path_element: &str, from: Id) -> (Vec<ReceivedEvent>, Id) {
        // Convert the IDs to `u128`s to cater for wrapping and add `Id::MAX + 1` to `from` if the
        // buffer wrapped and `from` represents an event from after the wrap.
        let threshold = Id::MAX - EVENT_COUNT;
        let from = if self.first_event_id >= threshold && from < threshold {
            from as u128 + Id::MAX as u128 + 1
        } else {
            from as u128
        };

        let id_filter = |id: u128, event: &SseData| -> Option<ReceivedEvent> {
            if id < from {
                return None;
            }

            let data = match event {
                SseData::DeployAccepted {
                    deploy: deploy_hash,
                } => {
                    let deploy_accepted = self.deploy_getter.get_test_deploy(*deploy_hash).unwrap();
                    serde_json::to_string(&DeployAccepted { deploy_accepted }).unwrap()
                }
                _ => serde_json::to_string(event).unwrap(),
            };

            Some(ReceivedEvent {
                id: Some(id as Id),
                data,
            })
        };

        let api_version_event = ReceivedEvent {
            id: None,
            data: serde_json::to_string(&SseData::ApiVersion(self.protocol_version)).unwrap(),
        };

        let filter = sse_server::get_filter(final_path_element).unwrap();
        let events: Vec<_> = iter::once(api_version_event)
            .chain(self.events.iter().enumerate().filter_map(|(id, event)| {
                let id = id as u128 + self.first_event_id as u128;
                if event.should_include(filter) {
                    id_filter(id, event)
                } else {
                    None
                }
            }))
            .collect();

        let final_id = events
            .last()
            .expect("should have events")
            .id
            .expect("should have ID");

        (events, final_id)
    }
/// Returns all the events which would have been received by a client via
/// `/events/<final_path_element>`, where the client connected just before `from` was emitted
/// from the server.  This includes the initial `ApiVersion` event.
///
/// Also returns the last event's ID,
Returns all the events which would have been received by a client via
`/events/`, where the client connected just before `from` was emitted
from the server.  This includes the initial `ApiVersion` event.

Also returns the last event's ID.
Returns all the events which would have been received by a client via ` / events / ` where the client connected just before ` from ` was emitted from the server . This includes the initial ` ApiVersion ` event . Also returns the last event ' s ID .
fn filtered_events(&self, final_path_element: &str, from: Id) -> (Vec<ReceivedEvent>, Id) {
        // Convert the IDs to `u128`s to cater for wrapping and add `Id::MAX + 1` to `from` if the
        // buffer wrapped and `from` represents an event from after the wrap.
        let threshold = Id::MAX - EVENT_COUNT;
        let from = if self.first_event_id >= threshold && from < threshold {
            from as u128 + Id::MAX as u128 + 1
        } else {
            from as u128
        };
        let id_filter = |id: u128, event: &SseData| -> Option<ReceivedEvent> {
            if id < from {
                return None;
            }
            let data = match event {
                SseData::DeployAccepted {
                    deploy: deploy_hash,
                } => {
                    let deploy_accepted = self.deploy_getter.get_test_deploy(*deploy_hash).unwrap();
                    serde_json::to_string(&DeployAccepted { deploy_accepted }).unwrap()
                }
                _ => serde_json::to_string(event).unwrap(),
            };
            Some(ReceivedEvent {
                id: Some(id as Id),
                data,
            })
        };
        let api_version_event = ReceivedEvent {
            id: None,
            data: serde_json::to_string(&SseData::ApiVersion(self.protocol_version)).unwrap(),
        };
        let filter = sse_server::get_filter(final_path_element).unwrap();
        let events: Vec<_> = iter::once(api_version_event)
            .chain(self.events.iter().enumerate().filter_map(|(id, event)| {
                let id = id as u128 + self.first_event_id as u128;
                if event.should_include(filter) {
                    id_filter(id, event)
                } else {
                    None
                }
            }))
            .collect();
        let final_id = events
            .last()
            .expect("should have events")
            .id
            .expect("should have ID");
        (events, final_id)
    }
fn filtered_events ( & self , final_path_element : & str , from : Id ) -> ( Vec < ReceivedEvent > , Id ) { // Convert the IDs to `u128`s to cater for wrapping and add `Id::MAX + 1` to `from` if the // buffer wrapped and `from` represents an event from after the wrap. let threshold = Id :: MAX - EVENT_COUNT ; let from = if self . first_event_id >= threshold && from < threshold { from as u128 + Id :: MAX as u128 + 1 } else { from as u128 } ; let id_filter = | id : u128 , event : & SseData | -> Option < ReceivedEvent > { if id < from { return None ; } let data = match event { SseData :: DeployAccepted { deploy : deploy_hash , } => { let deploy_accepted = self . deploy_getter . get_test_deploy ( * deploy_hash ) . unwrap ( ) ; serde_json :: to_string ( & DeployAccepted { deploy_accepted } ) . unwrap ( ) } _ => serde_json :: to_string ( event ) . unwrap ( ) , } ; Some ( ReceivedEvent { id : Some ( id as Id ) , data , } ) } ; let api_version_event = ReceivedEvent { id : None , data : serde_json :: to_string ( & SseData :: ApiVersion ( self . protocol_version ) ) . unwrap ( ) , } ; let filter = sse_server :: get_filter ( final_path_element ) . unwrap ( ) ; let events : Vec < _ > = iter :: once ( api_version_event ) . chain ( self . events . iter ( ) . enumerate ( ) . filter_map ( | ( id , event ) | { let id = id as u128 + self . first_event_id as u128 ; if event . should_include ( filter ) { id_filter ( id , event ) } else { None } } ) ) . collect ( ) ; let final_id = events . last ( ) . expect ( " " ) . id . expect ( " " ) ; ( events , final_id ) }
Returns all the events which would have been received by a client via
`/events/<final_path_element>`, where the client connected just before `from` was emitted
from the server.
Returns all the events which would have been received by a client via ` / events / <final_path_element > ` where the client connected just before ` from ` was emitted from the server .
&self
final_path_element
&str
from
Id
&self
final_path_element
&str
from
Id