Skip to main content

Resource

Trait Resource 

Source
pub trait Resource {
    // Required methods
    fn client(&self) -> &ComposioClient;
    fn telemetry_context(&self) -> &TelemetryContext;

    // Provided methods
    fn sanitize_payload<T>(&self, payload: T) -> T
       where T: Serialize + DeserializeOwned { ... }
    fn provider(&self) -> Option<String> { ... }
    fn create_method_event(
        &self,
        function_name: &str,
        provider: Option<&str>,
    ) -> Option<TelemetryData> { ... }
    fn push_telemetry_event(&self, event: Event) { ... }
    fn trace_method<F, R>(
        &self,
        function_name: &str,
        provider: Option<&str>,
        f: F,
    ) -> R
       where F: FnOnce() -> R { ... }
    fn trace_method_with_error<F, R, E>(
        &self,
        function_name: &str,
        provider: Option<&str>,
        f: F,
    ) -> Result<R, E>
       where F: FnOnce() -> Result<R, E>,
             E: Display { ... }
}
Expand description

Base resource trait for Composio resources

This trait provides the foundation for all Composio resource types, including telemetry tracking, method tracing, and payload sanitization.

Required Methods§

Source

fn client(&self) -> &ComposioClient

Get the client reference

Source

fn telemetry_context(&self) -> &TelemetryContext

Get telemetry context

Provided Methods§

Source

fn sanitize_payload<T>(&self, payload: T) -> T

Sanitize payload by removing sensitive information

This method filters out sensitive fields from payloads before logging. Override this method in specific resource implementations to customize which fields should be sanitized.

Source

fn provider(&self) -> Option<String>

Get the provider name for telemetry

Returns the provider name from the client configuration if available.

Source

fn create_method_event( &self, function_name: &str, provider: Option<&str>, ) -> Option<TelemetryData>

Create a telemetry event for a method call

This method creates a telemetry event with metadata about the current execution context, including timestamp, environment, and provider information.

Source

fn push_telemetry_event(&self, event: Event)

Push a telemetry event

Source

fn trace_method<F, R>( &self, function_name: &str, provider: Option<&str>, f: F, ) -> R
where F: FnOnce() -> R,

Trace a method execution with telemetry

Source

fn trace_method_with_error<F, R, E>( &self, function_name: &str, provider: Option<&str>, f: F, ) -> Result<R, E>
where F: FnOnce() -> Result<R, E>, E: Display,

Trace a method execution with error handling

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§