pub struct MethodSchema {
pub name: String,
pub description: String,
pub hash: String,
pub params: Option<Schema>,
pub returns: Option<Schema>,
pub streaming: bool,
pub bidirectional: bool,
pub request_type: Option<Schema>,
pub response_type: Option<Schema>,
}Expand description
Schema for a single method exposed by a plugin
Fields§
§name: StringMethod name (e.g., “echo”, “check”)
description: StringHuman-readable description of what this method does
hash: StringContent hash of the method definition (for cache invalidation) Generated by hashing the method signature within hub-macro
params: Option<Schema>JSON Schema for the method’s parameters (None if no params)
returns: Option<Schema>JSON Schema for the method’s return type (None if not specified)
streaming: boolWhether this method streams multiple events (true) or returns a single result (false)
streaming: true→ returnsAsyncGenerator<T>(multiple events)streaming: false→ returnsPromise<T>(single event, collected)
All methods use the same streaming protocol under the hood, but this flag tells clients how to present the result.
bidirectional: boolWhether this method supports bidirectional communication
When true, the server can send requests to the client during method execution and wait for responses (e.g., confirmations, prompts, selections).
request_type: Option<Schema>JSON Schema for the request type sent from server to client
Only relevant when bidirectional: true. Describes the structure of
requests the server may send during method execution.
response_type: Option<Schema>JSON Schema for the response type sent from client to server
Only relevant when bidirectional: true. Describes the structure of
responses the client should send in reply to server requests.
Implementations§
Source§impl MethodSchema
impl MethodSchema
Sourcepub fn new(
name: impl Into<String>,
description: impl Into<String>,
hash: impl Into<String>,
) -> MethodSchema
pub fn new( name: impl Into<String>, description: impl Into<String>, hash: impl Into<String>, ) -> MethodSchema
Create a new method schema with name, description, and hash
The hash should be computed from the method definition string within the hub-macro at compile time.
Sourcepub fn with_params(self, params: Schema) -> MethodSchema
pub fn with_params(self, params: Schema) -> MethodSchema
Add parameter schema
Sourcepub fn with_returns(self, returns: Schema) -> MethodSchema
pub fn with_returns(self, returns: Schema) -> MethodSchema
Add return type schema
Sourcepub fn with_streaming(self, streaming: bool) -> MethodSchema
pub fn with_streaming(self, streaming: bool) -> MethodSchema
Set the streaming flag
true→ method streams multiple events (useAsyncGenerator<T>)false→ method returns single result (usePromise<T>)
Sourcepub fn with_bidirectional(self, bidirectional: bool) -> MethodSchema
pub fn with_bidirectional(self, bidirectional: bool) -> MethodSchema
Set whether this method supports bidirectional communication
When true, the server can send requests to the client during method execution and wait for responses.
Sourcepub fn with_request_type(self, schema: Schema) -> MethodSchema
pub fn with_request_type(self, schema: Schema) -> MethodSchema
Set the JSON Schema for server-to-client request types
Only relevant when bidirectional: true. Use schema_for!(YourRequestType)
to generate the schema.
Sourcepub fn with_response_type(self, schema: Schema) -> MethodSchema
pub fn with_response_type(self, schema: Schema) -> MethodSchema
Set the JSON Schema for client-to-server response types
Only relevant when bidirectional: true. Use schema_for!(YourResponseType)
to generate the schema.
Sourcepub fn with_standard_bidirectional(self) -> MethodSchema
pub fn with_standard_bidirectional(self) -> MethodSchema
Configure method for standard bidirectional communication
Sets bidirectional: true and configures request/response types to use
StandardRequest and StandardResponse, which support common UI patterns
like confirmations, prompts, and selections.
Trait Implementations§
Source§impl Clone for MethodSchema
impl Clone for MethodSchema
Source§fn clone(&self) -> MethodSchema
fn clone(&self) -> MethodSchema
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MethodSchema
impl Debug for MethodSchema
Source§impl<'de> Deserialize<'de> for MethodSchema
impl<'de> Deserialize<'de> for MethodSchema
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<MethodSchema, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<MethodSchema, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for MethodSchema
impl JsonSchema for MethodSchema
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl Serialize for MethodSchema
impl Serialize for MethodSchema
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for MethodSchema
impl RefUnwindSafe for MethodSchema
impl Send for MethodSchema
impl Sync for MethodSchema
impl Unpin for MethodSchema
impl UnsafeUnpin for MethodSchema
impl UnwindSafe for MethodSchema
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more