Trait Utility
pub trait Utility:
Send
+ Sync
+ 'static {
// Required methods
fn new(context: UtilityContext) -> Result<Self, ApplicationError>
where Self: Sized;
fn invoke(
&self,
request: UtilityRequest,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, CommandError>> + Send + '_>>;
// Provided methods
fn create_session(
&self,
_request: UtilitySessionRequest,
) -> Result<Box<dyn UtilitySession>, ApplicationError> { ... }
fn shutdown(&self) -> Result<(), ApplicationError> { ... }
}Expand description
Stateful Rust implementation hosted in a sandboxed Chromium process.
Required Methods§
fn new(context: UtilityContext) -> Result<Self, ApplicationError>where
Self: Sized,
fn new(context: UtilityContext) -> Result<Self, ApplicationError>where
Self: Sized,
Creates service state after Chromium launches the utility process.
fn invoke(
&self,
request: UtilityRequest,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, CommandError>> + Send + '_>>
fn invoke( &self, request: UtilityRequest, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, CommandError>> + Send + '_>>
Handles one binary request without blocking the Chromium utility sequence.
Implementations should observe request.is_cancelled() during long work.
Provided Methods§
fn create_session(
&self,
_request: UtilitySessionRequest,
) -> Result<Box<dyn UtilitySession>, ApplicationError>
fn create_session( &self, _request: UtilitySessionRequest, ) -> Result<Box<dyn UtilitySession>, ApplicationError>
Creates one long-lived session in this supervised Utility process.
fn shutdown(&self) -> Result<(), ApplicationError>
fn shutdown(&self) -> Result<(), ApplicationError>
Performs service-specific cleanup before the process becomes idle.