Skip to main content

thrift

Attribute Macro thrift 

Source
#[thrift]
Expand description

Generate Apache Thrift schema from an impl block.

§Example

use server_less::thrift;

struct UserService;

#[thrift(namespace = "users")]
impl UserService {
    /// Get user by ID
    fn get_user(&self, id: String) -> String { ... }

    /// Create a new user
    fn create_user(&self, name: String, email: String) -> String { ... }
}

// Get the Thrift schema
let schema = UserService::thrift_schema();

// Write to file for use with thrift compiler
UserService::write_thrift("idl/users.thrift")?;

The generated schema can be used with the Thrift compiler to generate client/server code in various languages.