/// Subscribes to events provided in the `events` vector.
///
/// The client might request to subscribe to events that it's not allowed to see. Events
/// that are allowed should have been defined in its manifest and either offered to it or
/// requested from the current realm.
Subscribes to events provided in the `events` vector.
The client might request to subscribe to events that it's not allowed to see. Events
that are allowed should have been defined in its manifest and either offered to it or
requested from the current realm.
Subscribes to events provided in the ` events ` vector . The client might request to subscribe to events that it ' s not allowed to see . Events that are allowed should have been defined in its manifest and either offered to it or requested from the current realm .
pub async fn subscribe(
        &mut self,
        events: Vec<CapabilityName>,
    ) -> Result<EventStream, EventsError> {
        // Register event capabilities if any. It identifies the sources of these events (might be the
        // containing realm or this realm itself). It consturcts an "allow-list tree" of events and
        // realms.
        let events = if self.debug {
            events
                .into_iter()
                .map(|event| RoutedEvent {
                    source_name: event.clone(),
                    scope_monikers: hashset!(AbsoluteMoniker::root()),
                })
                .collect()
        } else {
            let route_result =
                self.route_events(&events).await.map_err(|e| EventsError::RoutingFailed(e))?;
            if route_result.len() != events.len() {
                let names = events
                    .into_iter()
                    .filter(|event| !route_result.contains_event(&event))
                    .collect();
                return Err(EventsError::NotAvailable { names });
            }
            route_result.to_vec()
        };
        // Create an event stream for the given events
        if let Some(registry) = self.registry.upgrade() {
            return Ok(registry.subscribe(&self.sync_mode, events).await);
        }
        Err(EventsError::RegistryNotFound)
    }
pub async fn subscribe ( & mut self , events : Vec < CapabilityName > , ) -> Result < EventStream , EventsError > { // Register event capabilities if any. It identifies the sources of these events (might be the // containing realm or this realm itself). It consturcts an "allow-list tree" of events and // realms. let events = if self . debug { events . into_iter ( ) . map ( | event | RoutedEvent { source_name : event . clone ( ) , scope_monikers : hashset ! ( AbsoluteMoniker root ( ) ) , } ) . collect ( ) } else { let route_result = self . route_events ( & events ) . await . map_err ( | e | EventsError :: RoutingFailed ( e ) ) ? ; if route_result . len ( ) != events . len ( ) { let names = events . into_iter ( ) . filter ( | event | ! route_result . contains_event ( & event ) ) . collect ( ) ; return Err ( EventsError :: NotAvailable { names } ) ; } route_result . to_vec ( ) } ; // Create an event stream for the given events if let Some ( registry ) = self . registry . upgrade ( ) { return Ok ( registry . subscribe ( & self . sync_mode , events ) . await ) ; } Err ( EventsError :: RegistryNotFound ) }
Subscribes to events provided in the `events` vector.
Subscribes to events provided in the ` events ` vector .
&mut self
events
Vec<CapabilityName>