event_type_to_class

Function event_type_to_class 

Source
pub fn event_type_to_class(event_type: &str) -> Option<EventType>
Expand description

Converts an event type string to its corresponding EventType enum.

This function maps event type names (as they appear in control protocol messages) to the EventType enum used for event subscription.

§Arguments

  • event_type - The event type string (case-insensitive)

§Returns

Some(EventType) if the event type is recognized, None otherwise.

§Example

use stem_rs::response::events::event_type_to_class;
use stem_rs::EventType;

assert_eq!(event_type_to_class("BW"), Some(EventType::Bw));
assert_eq!(event_type_to_class("CIRC"), Some(EventType::Circ));
assert_eq!(event_type_to_class("bw"), Some(EventType::Bw)); // Case-insensitive
assert_eq!(event_type_to_class("UNKNOWN"), None);

§Note

The STATUS_CLIENT, STATUS_GENERAL, and STATUS_SERVER event types all map to EventType::Status since they share the same structure.