
需要先安装protoc(Protocol Buffers Compiler),可据此Protobuf Compiler Installation下载
第一步:创建项目
-
创建两个新的Rust项目,分别作为服务端与客户端:
cargo new rust_grpc_server
cargo new rust_grpc_client -
分别在项目根目录创建
proto
文件夹,并在其中创建一个叫hello.proto
的文件
第二步:编写.proto
文件
在proto/hello.proto
文件中分别写入以下内容: