pub struct Caster { /* private fields */ }Expand description
Caster connects to a Rune Runtime and registers Rune handlers.
Implementations§
Source§impl Caster
impl Caster
Sourcepub fn new(config: CasterConfig) -> Self
pub fn new(config: CasterConfig) -> Self
Create a new Caster with the given configuration.
Sourcepub fn config(&self) -> &CasterConfig
pub fn config(&self) -> &CasterConfig
Returns a reference to the configuration.
Sourcepub fn rune_count(&self) -> usize
pub fn rune_count(&self) -> usize
Returns the number of registered runes.
Sourcepub fn get_rune_config(&self, name: &str) -> Option<RuneConfig>
pub fn get_rune_config(&self, name: &str) -> Option<RuneConfig>
Returns the config of a registered rune by name.
Sourcepub fn is_stream_rune(&self, name: &str) -> bool
pub fn is_stream_rune(&self, name: &str) -> bool
Check if a rune is registered as a stream handler.
Sourcepub fn stop(&self)
pub fn stop(&self)
Signal the Caster to stop its run loop.
Safe to call from any thread or task. The run() method
will return shortly after this is called. Idempotent — calling
multiple times is safe.
Sourcepub fn rune_accepts_files(&self, name: &str) -> bool
pub fn rune_accepts_files(&self, name: &str) -> bool
Check if a rune handler accepts file attachments.
Sourcepub fn rune<F, Fut>(&self, config: RuneConfig, handler: F) -> SdkResult<()>
pub fn rune<F, Fut>(&self, config: RuneConfig, handler: F) -> SdkResult<()>
Register a unary rune handler.
The handler receives (RuneContext, Bytes) and returns Result<Bytes>.
§Errors
Returns SdkError::DuplicateRune if a rune with the same name already exists.
Sourcepub fn rune_with_files<F, Fut>(
&self,
config: RuneConfig,
handler: F,
) -> SdkResult<()>
pub fn rune_with_files<F, Fut>( &self, config: RuneConfig, handler: F, ) -> SdkResult<()>
Register a unary rune handler that accepts file attachments.
Sourcepub fn stream_rune<F, Fut>(
&self,
config: RuneConfig,
handler: F,
) -> SdkResult<()>where
F: Fn(RuneContext, Bytes, StreamSender) -> Fut + Send + Sync + 'static,
Fut: Future<Output = SdkResult<()>> + Send + 'static,
pub fn stream_rune<F, Fut>(
&self,
config: RuneConfig,
handler: F,
) -> SdkResult<()>where
F: Fn(RuneContext, Bytes, StreamSender) -> Fut + Send + Sync + 'static,
Fut: Future<Output = SdkResult<()>> + Send + 'static,
Register a streaming rune handler.
The handler receives (RuneContext, Bytes, StreamSender) and returns Result<()>.
Sourcepub fn stream_rune_with_files<F, Fut>(
&self,
config: RuneConfig,
handler: F,
) -> SdkResult<()>where
F: Fn(RuneContext, Bytes, Vec<FileAttachment>, StreamSender) -> Fut + Send + Sync + 'static,
Fut: Future<Output = SdkResult<()>> + Send + 'static,
pub fn stream_rune_with_files<F, Fut>(
&self,
config: RuneConfig,
handler: F,
) -> SdkResult<()>where
F: Fn(RuneContext, Bytes, Vec<FileAttachment>, StreamSender) -> Fut + Send + Sync + 'static,
Fut: Future<Output = SdkResult<()>> + Send + 'static,
Register a streaming rune handler that accepts file attachments.
Auto Trait Implementations§
impl Freeze for Caster
impl RefUnwindSafe for Caster
impl Send for Caster
impl Sync for Caster
impl Unpin for Caster
impl UnsafeUnpin for Caster
impl UnwindSafe for Caster
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> 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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request