one commit contains all impl

This commit is contained in:
2022-10-21 15:09:22 +08:00
commit e871ec2b29
17 changed files with 2117 additions and 0 deletions

13
libvanity/Cargo.toml Normal file
View File

@ -0,0 +1,13 @@
[package]
name = "libvanity"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
tonic = "0.8"
prost = "0.11"
[build-dependencies]
tonic-build = "0.8"

11
libvanity/build.rs Normal file
View File

@ -0,0 +1,11 @@
fn main() -> std::io::Result<()> {
let descriptor_path =
std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap()).join("descriptor.bin");
tonic_build::configure()
.build_client(true)
.build_server(true)
.file_descriptor_set_path(descriptor_path)
.compile(&["vanity.proto", "worker.proto"], &["protos"])?;
Ok(())
}

View File

@ -0,0 +1,15 @@
syntax = "proto3";
package vanity;
message VanityRequest {
string pattern = 1;
}
message VanityResponse {
string result = 1;
}
service VanityService {
rpc RequestVanity(VanityRequest) returns (VanityResponse);
}

View File

@ -0,0 +1,26 @@
syntax = "proto3";
package worker;
import "vanity.proto";
message NewRequest {
uint64 id = 1;
string pattern = 2;
}
message Request {
oneof NewOrDone {
NewRequest new = 1;
uint64 done = 2;
}
}
message Result {
uint64 id = 1;
string result = 2;
}
service Worker {
rpc Poll(stream Result) returns (stream Request);
}

9
libvanity/src/lib.rs Normal file
View File

@ -0,0 +1,9 @@
pub mod vanity {
tonic::include_proto!("vanity");
}
pub mod worker {
tonic::include_proto!("worker");
}
pub const FILE_DESCRIPTOR_SET: &[u8] = tonic::include_file_descriptor_set!("descriptor");