Skip to main content

grpc

Attribute Macro grpc 

Source
#[grpc]
Expand description

Generate Protocol Buffers schema from an impl block.

§Example

use server_less::grpc;

struct UserService;

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

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

// Get the proto schema
let proto = UserService::proto_schema();

// Write to file for use with tonic-build
UserService::write_proto("proto/users.proto")?;

The generated schema can be used with tonic-build in your build.rs to generate the full gRPC client/server implementation.