pub struct InitSchema {
pub methods: HashMap<String, MethodSchema>,
pub events: HashMap<String, EventSchema>,
}Expand description
Schema describing available methods and events.
Used to build the $init message that tells the parent
what methods and events this worker supports.
Fields§
§methods: HashMap<String, MethodSchema>Map of method names to their definitions.
events: HashMap<String, EventSchema>Map of event names to their definitions.
Implementations§
Source§impl InitSchema
impl InitSchema
Sourcepub fn add_method(&mut self, name: &str, id: u16, response: ResponseType)
pub fn add_method(&mut self, name: &str, id: u16, response: ResponseType)
Add a method to the schema.
§Arguments
name- Method name (e.g., “echo”)id- Assigned method ID (must be 1-65534)response- Expected response type
Sourcepub fn add_event(&mut self, name: &str, id: u16)
pub fn add_event(&mut self, name: &str, id: u16)
Add an event to the schema.
§Arguments
name- Event name (e.g., “progress”)id- Assigned event ID (must be 1-65534)
Sourcepub fn get_method(&self, name: &str) -> Option<&MethodSchema>
pub fn get_method(&self, name: &str) -> Option<&MethodSchema>
Get a method by name.
Sourcepub fn get_event(&self, name: &str) -> Option<&EventSchema>
pub fn get_event(&self, name: &str) -> Option<&EventSchema>
Get an event by name.
Trait Implementations§
Source§impl Clone for InitSchema
impl Clone for InitSchema
Source§fn clone(&self) -> InitSchema
fn clone(&self) -> InitSchema
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for InitSchema
impl Debug for InitSchema
Source§impl Default for InitSchema
impl Default for InitSchema
Source§fn default() -> InitSchema
fn default() -> InitSchema
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for InitSchema
impl RefUnwindSafe for InitSchema
impl Send for InitSchema
impl Sync for InitSchema
impl Unpin for InitSchema
impl UnwindSafe for InitSchema
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more