Update dependencies and refactor application structure
- Updated various dependencies in `Cargo.toml` to their latest versions, including `tonic`, `tokio`, and `url`. - Refactored `ServerConfig` to include a new `grpc_target` field, replacing the previous bind and port fields. - Removed the `routes.rs` file and integrated its functionality into the main application logic. - Enhanced the `PrinterInfo` struct to include additional fields for printer details. - Simplified the main application flow by directly using the `ControlService` for handling requests. - Cleaned up unused code and improved overall organization of the project structure.
This commit is contained in:
82
proto/control.proto
Normal file
82
proto/control.proto
Normal file
@@ -0,0 +1,82 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package control.v1;
|
||||
|
||||
service Control {
|
||||
rpc ControlStream(stream ClientMessage) returns (stream ServerMessage);
|
||||
}
|
||||
|
||||
message ClientMessage {
|
||||
oneof msg {
|
||||
Hello hello = 1;
|
||||
PrintResult result = 2;
|
||||
Pong pong = 3;
|
||||
PrinterUpdate printers = 4;
|
||||
}
|
||||
}
|
||||
|
||||
message ServerMessage {
|
||||
oneof msg {
|
||||
PrintInstruction print = 1;
|
||||
Ping ping = 2;
|
||||
}
|
||||
}
|
||||
|
||||
message Hello {
|
||||
string client_id = 1;
|
||||
string version = 2;
|
||||
string hostname = 3;
|
||||
repeated PrinterInfo printers = 4;
|
||||
}
|
||||
|
||||
message Ping {
|
||||
string nonce = 1;
|
||||
}
|
||||
|
||||
message Pong {
|
||||
string nonce = 1;
|
||||
}
|
||||
|
||||
message PrintInstruction {
|
||||
string request_id = 1;
|
||||
bytes pdf_data = 2;
|
||||
PrintParams params = 3;
|
||||
}
|
||||
|
||||
message PrintParams {
|
||||
uint32 copies = 1;
|
||||
string duplex = 2; // one_sided, long_edge, short_edge
|
||||
string color = 3; // auto, color, monochrome
|
||||
string media = 4;
|
||||
string quality = 5; // draft, normal, high
|
||||
string orientation = 6; // portrait, landscape
|
||||
string job_name = 7;
|
||||
string printer = 8;
|
||||
}
|
||||
|
||||
message PrintResult {
|
||||
string request_id = 1;
|
||||
bool ok = 2;
|
||||
string printer = 3;
|
||||
string message = 4;
|
||||
uint32 retries_used = 5;
|
||||
}
|
||||
|
||||
message PrinterUpdate {
|
||||
repeated PrinterInfo printers = 1;
|
||||
}
|
||||
|
||||
message PrinterInfo {
|
||||
string id = 1;
|
||||
string name = 2;
|
||||
string host = 3;
|
||||
string uri = 4;
|
||||
string state = 5;
|
||||
bool accepting_jobs = 6;
|
||||
bool color_supported = 7;
|
||||
uint32 active_jobs = 8;
|
||||
uint32 ppm = 9;
|
||||
uint32 ppm_color = 10;
|
||||
repeated string reasons = 11;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user