├── test_certs ├── empty_cert.pem ├── empty_client_key ├── invalid_cert.pem ├── invalid_client_key ├── valid_client_cert.pem ├── valid_cert.pem └── valid_client_key ├── .gitignore ├── src ├── proto │ ├── mod.rs │ ├── mod.proto │ └── mod_pb.rs ├── client │ ├── hostname.rs │ └── mod.rs ├── lib.rs ├── main.rs └── transport │ └── mod.rs ├── Makefile ├── tests └── from.rs ├── .travis.yml ├── examples ├── query.rs ├── event.rs └── event_tls.rs ├── Cargo.toml └── README.md /test_certs/empty_cert.pem: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test_certs/empty_client_key: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | Cargo.lock 3 | test_riemann_cli.sh 4 | -------------------------------------------------------------------------------- /src/proto/mod.rs: -------------------------------------------------------------------------------- 1 | mod mod_pb; 2 | 3 | pub use self::mod_pb::*; -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | src/proto/mod.rs: src/proto/mod.proto 2 | protoc --rust_out $(dir $@) $^ 3 | -------------------------------------------------------------------------------- /test_certs/invalid_cert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | wfvp7OOGAN6dEOM4+qR9sdjoSYKEBpsr6GtPAQw4dy753ec5 3 | -----END CERTIFICATE----- 4 | -------------------------------------------------------------------------------- /test_certs/invalid_client_key: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIJKQIBAAKCAgEAtqQjF69pDrkmTVyH2GFAGsIim+r6H2rl53h1hTO3cbuYFVrF 3 | -----END RSA PRIVATE KEY----- 4 | -------------------------------------------------------------------------------- /tests/from.rs: -------------------------------------------------------------------------------- 1 | use riemann_client::proto::Query; 2 | 3 | #[test] 4 | fn query_from_str() { 5 | Query::from("hello world"); 6 | } 7 | 8 | #[test] 9 | fn query_from_string() { 10 | Query::from("hello world".to_string()); 11 | } 12 | 13 | #[test] 14 | fn query_from_query() { 15 | Query::from(Query::new()); 16 | } 17 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: rust 2 | rust: 3 | - stable 4 | - beta 5 | - nightly 6 | script: 7 | - cargo build --verbose 8 | - cargo test --verbose 9 | - cargo build --verbose --release 10 | sudo: false 11 | before_deploy: "echo $PWD" 12 | deploy: 13 | provider: releases 14 | api_key: 15 | secure: mwghbw0K6BpgBkxJhhkf6CFIhB4WYwgLZjC4O2MQW/9lknbgT1tEYt4adswLjf3sGeZjvgnwemdVuXFrKP3JDgdb9pVtOGPvUpYAMwUSUjYtE3YX9yEINvPsVKCPfOQhaXAye6q7c00fdkwW+3waHJLNsMnbYw/cD12K8jatsSM= 16 | file: target/release/riemann-cli 17 | on: 18 | repo: borntyping/rust-riemann_client 19 | rust: stable 20 | tags: true 21 | -------------------------------------------------------------------------------- /examples/query.rs: -------------------------------------------------------------------------------- 1 | //! Prints all events from the index 2 | 3 | use riemann_client::Client; 4 | 5 | fn main() { 6 | let mut client = Client::connect(&("localhost", 5555)).unwrap(); 7 | let events = client.query("true").unwrap(); 8 | 9 | println!( 10 | "{:<10} {:<10} {:<55} {:<10} {:<10}", 11 | "HOSTNAME", "TIME", "SERVICE", "METRIC", "STATE" 12 | ); 13 | 14 | for event in events { 15 | println!( 16 | "{:<10} {:<10} {:<55} {:<10} {:<10}", 17 | event.get_host(), 18 | event.get_time(), 19 | event.get_service(), 20 | event.get_metric_f(), 21 | event.get_state() 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /examples/event.rs: -------------------------------------------------------------------------------- 1 | use riemann_client::proto::Event; 2 | use riemann_client::Client; 3 | 4 | fn main() { 5 | let mut client = Client::connect(&("localhost", 5555)).unwrap(); 6 | 7 | client 8 | .event({ 9 | let mut event = Event::new(); 10 | event.set_service("rust-riemann_client".to_string()); 11 | event.set_state("ok".to_string()); 12 | event.set_metric_d(128.128); 13 | event 14 | }) 15 | .unwrap(); 16 | 17 | // client.event(riemann_client::Event { 18 | // service: "rust-riemann_client", 19 | // state: "ok", 20 | // metric_d: 128.128 21 | // ..Event::new() 22 | // }).unwrap() 23 | } 24 | -------------------------------------------------------------------------------- /examples/event_tls.rs: -------------------------------------------------------------------------------- 1 | use riemann_client::proto::Event; 2 | use riemann_client::Client; 3 | 4 | fn main() { 5 | let mut client = 6 | Client::connect_tls("myhost_name", 5554, "myCA.pem", "mycert.pem", "mykey").unwrap(); 7 | 8 | client 9 | .event({ 10 | let mut event = Event::new(); 11 | event.set_service("rust-riemann_client".to_string()); 12 | event.set_state("ok".to_string()); 13 | event.set_metric_d(128.128); 14 | event 15 | }) 16 | .unwrap(); 17 | 18 | // client.event(riemann_client::Event { 19 | // service: "rust-riemann_client", 20 | // state: "ok", 21 | // metric_d: 128.128 22 | // ..Event::new() 23 | // }).unwrap() 24 | } 25 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = ["Sam Clements "] 3 | description = "A Riemann client library" 4 | edition = "2018" 5 | license = "MIT" 6 | name = "riemann_client" 7 | repository = "https://github.com/borntyping/rust-riemann_client" 8 | version = "0.9.0" 9 | 10 | [[bin]] 11 | name = "riemann-cli" 12 | path = "src/main.rs" 13 | test = false 14 | 15 | [dependencies] 16 | libc = "0.2.84" 17 | protobuf = "2.20.0" 18 | rustls = "0.19.0" 19 | rustls-pemfile = "0.2.0" 20 | webpki = "0.21.4" 21 | webpki-roots = "0.21.0" 22 | 23 | [dependencies.docopt] 24 | optional = true 25 | version = "1.1.0" 26 | 27 | [dependencies.serde] 28 | optional = true 29 | version = "1.0.123" 30 | 31 | [features] 32 | default = ["docopt", "serde"] 33 | 34 | [lib] 35 | doctest = false 36 | name = "riemann_client" 37 | -------------------------------------------------------------------------------- /src/client/hostname.rs: -------------------------------------------------------------------------------- 1 | //! Wrapper around the hostname function from libc 2 | 3 | use std::iter::repeat; 4 | use std::io::{Error,ErrorKind,Result}; 5 | 6 | use libc::{c_char,c_int,size_t}; 7 | 8 | extern { 9 | pub fn gethostname(name: *mut c_char, size: size_t) -> c_int; 10 | } 11 | 12 | /// Calls `gethostname` 13 | pub fn hostname() -> Result { 14 | // Create a buffer for the hostname to be copied into 15 | let buffer_len: usize = 255; 16 | let mut buffer: Vec = repeat(0).take(buffer_len).collect(); 17 | 18 | let error = unsafe { 19 | gethostname(buffer.as_mut_ptr() as *mut c_char, buffer_len as size_t) 20 | }; 21 | 22 | if error != 0 { 23 | return Err(Error::last_os_error()); 24 | } 25 | 26 | // Find the end of the string and truncate the vector to that length 27 | let len = buffer.iter().position(|b| *b == 0).unwrap_or(buffer_len); 28 | buffer.truncate(len); 29 | 30 | // Create an owned string from the buffer, transforming UTF-8 errors into IO errors 31 | String::from_utf8(buffer).map_err(|e| Error::new(ErrorKind::Other, e)) 32 | } 33 | 34 | #[cfg(test)] 35 | #[test] 36 | fn test_hostname() { 37 | hostname().unwrap(); 38 | } 39 | -------------------------------------------------------------------------------- /src/proto/mod.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | option java_package = "io.riemann.riemann"; 3 | option java_outer_classname = "Proto"; 4 | 5 | // Deprecated; state was used by early versions of the protocol, but not any 6 | // more. 7 | message State { 8 | optional int64 time = 1; 9 | optional string state = 2; 10 | optional string service = 3; 11 | optional string host = 4; 12 | optional string description = 5; 13 | optional bool once = 6; 14 | repeated string tags = 7; 15 | optional float ttl = 8; 16 | } 17 | 18 | message Event { 19 | optional int64 time = 1; 20 | optional string state = 2; 21 | optional string service = 3; 22 | optional string host = 4; 23 | optional string description = 5; 24 | repeated string tags = 7; 25 | optional float ttl = 8; 26 | repeated Attribute attributes = 9; 27 | 28 | optional int64 time_micros = 10; 29 | optional sint64 metric_sint64 = 13; 30 | optional double metric_d = 14; 31 | optional float metric_f = 15; 32 | } 33 | 34 | message Query { 35 | optional string string = 1; 36 | } 37 | 38 | message Msg { 39 | optional bool ok = 2; 40 | optional string error = 3; 41 | repeated State states = 4; 42 | optional Query query = 5; 43 | repeated Event events = 6; 44 | } 45 | 46 | message Attribute { 47 | required string key = 1; 48 | optional string value = 2; 49 | } 50 | -------------------------------------------------------------------------------- /test_certs/valid_client_cert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE REQUEST----- 2 | MIIEszCCApsCAQAwbjELMAkGA1UEBhMCRlIxFTATBgNVBAcMDERlZmF1bHQgQ2l0 3 | eTEcMBoGA1UECgwTRGVmYXVsdCBDb21wYW55IEx0ZDEUMBIGA1UECwwLQ2xpZW50 4 | IGNlcnQxFDASBgNVBAMMC0NsaWVudCBDZXJ0MIICIjANBgkqhkiG9w0BAQEFAAOC 5 | Ag8AMIICCgKCAgEAtqQjF69pDrkmTVyH2GFAGsIim+r6H2rl53h1hTO3cbuYFVrF 6 | YmmlStxTqnU9u3u1qSGdyV/Gc9LgANSOGDcm5G3LO3gI5To1v+O4k9NHSk/9WDep 7 | zR39sc6ikw4zC6TXS2CbhpvXuJ6CilPTTPU8eaIjKM7D2WrIZwa9ilbxo+JbJCgL 8 | cz+HZRb/Zy5ty5xVP/yfRd7ILj+Dr0C4FmvhZxOJ6zAKQZ2O8mcSHh12p3eEivwH 9 | 7WMh+znNurss5uCdTVlA9NKFHpMsLYvwj4cKMxo/aK/vgPrabMwsHdQeX0hIn+OA 10 | vXBLLJVuYfb85T9SvjFzFLj9EJfFcdDouWM/yGxxqqw7I+0o2GO8qpyN3TAtM3It 11 | C8Ejus+I3IlNuT0p0bAy7wvctMBW9a/xBl/8RbM8m+jXE1bRpzM6kcQj0ShZzJC9 12 | x9JjSFd7uxmvMBTZ+XRKyI143/Q0921d42UHiqaQgTWt6DFXEXKsRPJchXNfoDYH 13 | SUoMjn71IYP+A6b9muf3H9o0XV1dVf9SUE9LYlAz5sgv23cG/q4Hgkjukv5K3Xli 14 | EIRNVMearVgHX6T7yqFsaWfUwHiyB7S5aNhEdD9D5MWpLXmUzp0B5nPWWrlwb8z+ 15 | fu78TqVzoCGkF3Nb07+qiwabN0c8vmX5Y9cKYdjW4Do8HbU2f6j5K5lIwQ0CAwEA 16 | AaAAMA0GCSqGSIb3DQEBCwUAA4ICAQBIP0OEy2x2DZuPEcxXic6pSx5vbTXq9tnB 17 | eyQXci8lbnpuJZ80cAjuhMOYbS0Gyi4Yk7aXzuRb8ME1IEf4taxCLcw/emMZtKkn 18 | q5zZGb6oRhZ/slptLVb0I6xr4AY56DWMTZ6T/adu26v2ZyyVnu2FW54K+jsHOOcr 19 | dfPRblz9jzPX9DOB/HavJoflFoO22DhQDpn1SjxxN9HSw9SyRqIrae75XvlvxZAJ 20 | EmwewpK/oKRZoBeod8fK48y8ka5z9SKUw6eV01bG7YbruzOj8f/wJznzS3tql9ym 21 | LFzcgt71D2jp9juYWKpsm9PIPKdXMyo06qBKhg2Miy4su9rqb1xOTl/PIm1Jl44i 22 | xRYCtPkhoK/2/BRG2DUNuE6ODpJD8fIZFh/xDQafyWFZWFLspNNzR4R4sLgojKfa 23 | +fuEE0DXgO4UNW7rKgrq0r5Xz6TEGMb8mn7xspS05gTwo3nyte0OxqIcQW1PuXdh 24 | Xe+MOHaJ5MfO18JxhjeGF0wb2nK4sMJigFmySnNb0cx7XtGCvsUo4G11FQlhcASG 25 | 2+D1n5GtQ1/cQn827n/jJeOMYP19RrBWjQoPZUsBH8C4UIERa+h+cvpgkiGTfwQu 26 | HfAP142dVY9p2dFDB4TiTBb0WC6D28/XnVg7pLpwhtO3JW11bDjY74y2+QY37iVL 27 | KnTLx/TP3w== 28 | -----END CERTIFICATE REQUEST----- 29 | -------------------------------------------------------------------------------- /test_certs/valid_cert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIFYDCCBEigAwIBAgIQQAF3ITfU6UK47naqPGQKtzANBgkqhkiG9w0BAQsFADA/ 3 | MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT 4 | DkRTVCBSb290IENBIFgzMB4XDTIxMDEyMDE5MTQwM1oXDTI0MDkzMDE4MTQwM1ow 5 | TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh 6 | cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwggIiMA0GCSqGSIb3DQEB 7 | AQUAA4ICDwAwggIKAoICAQCt6CRz9BQ385ueK1coHIe+3LffOJCMbjzmV6B493XC 8 | ov71am72AE8o295ohmxEk7axY/0UEmu/H9LqMZshftEzPLpI9d1537O4/xLxIZpL 9 | wYqGcWlKZmZsj348cL+tKSIG8+TA5oCu4kuPt5l+lAOf00eXfJlII1PoOK5PCm+D 10 | LtFJV4yAdLbaL9A4jXsDcCEbdfIwPPqPrt3aY6vrFk/CjhFLfs8L6P+1dy70sntK 11 | 4EwSJQxwjQMpoOFTJOwT2e4ZvxCzSow/iaNhUd6shweU9GNx7C7ib1uYgeGJXDR5 12 | bHbvO5BieebbpJovJsXQEOEO3tkQjhb7t/eo98flAgeYjzYIlefiN5YNNnWe+w5y 13 | sR2bvAP5SQXYgd0FtCrWQemsAXaVCg/Y39W9Eh81LygXbNKYwagJZHduRze6zqxZ 14 | Xmidf3LWicUGQSk+WT7dJvUkyRGnWqNMQB9GoZm1pzpRboY7nn1ypxIFeFntPlF4 15 | FQsDj43QLwWyPntKHEtzBRL8xurgUBN8Q5N0s8p0544fAQjQMNRbcTa0B7rBMDBc 16 | SLeCO5imfWCKoqMpgsy6vYMEG6KDA0Gh1gXxG8K28Kh8hjtGqEgqiNx2mna/H2ql 17 | PRmP6zjzZN7IKw0KKP/32+IVQtQi0Cdd4Xn+GOdwiK1O5tmLOsbdJ1Fu/7xk9TND 18 | TwIDAQABo4IBRjCCAUIwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYw 19 | SwYIKwYBBQUHAQEEPzA9MDsGCCsGAQUFBzAChi9odHRwOi8vYXBwcy5pZGVudHJ1 20 | c3QuY29tL3Jvb3RzL2RzdHJvb3RjYXgzLnA3YzAfBgNVHSMEGDAWgBTEp7Gkeyxx 21 | +tvhS5B1/8QVYIWJEDBUBgNVHSAETTBLMAgGBmeBDAECATA/BgsrBgEEAYLfEwEB 22 | ATAwMC4GCCsGAQUFBwIBFiJodHRwOi8vY3BzLnJvb3QteDEubGV0c2VuY3J5cHQu 23 | b3JnMDwGA1UdHwQ1MDMwMaAvoC2GK2h0dHA6Ly9jcmwuaWRlbnRydXN0LmNvbS9E 24 | U1RST09UQ0FYM0NSTC5jcmwwHQYDVR0OBBYEFHm0WeZ7tuXkAXOACIjIGlj26Ztu 25 | MA0GCSqGSIb3DQEBCwUAA4IBAQAKcwBslm7/DlLQrt2M51oGrS+o44+/yQoDFVDC 26 | 5WxCu2+b9LRPwkSICHXM6webFGJueN7sJ7o5XPWioW5WlHAQU7G75K/QosMrAdSW 27 | 9MUgNTP52GE24HGNtLi1qoJFlcDyqSMo59ahy2cI2qBDLKobkx/J3vWraV0T9VuG 28 | WCLKTVXkcGdtwlfFRjlBz4pYg1htmf5X6DYO8A4jqv2Il9DjXA6USbW1FzXSLr9O 29 | he8Y4IWS6wY7bCkjCWDcRQJMEhg76fsO3txE+FiYruq9RUWhiF1myv4Q6W+CyBFC 30 | Dfvp7OOGAN6dEOM4+qR9sdjoSYKEBpsr6GtPAQw4dy753ec5 31 | -----END CERTIFICATE----- 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # riemann_client [![](https://img.shields.io/crates/v/riemann_client.svg)](https://crates.io/crates/riemann_client) [![](https://img.shields.io/crates/l/riemann_client.svg)](https://crates.io/crates/riemann_client) [![](https://img.shields.io/travis/borntyping/rust-riemann_client.svg)](https://travis-ci.org/borntyping/rust-riemann_client) 2 | 3 | A [Riemann](http://riemann.io/) client library and command line interface. 4 | 5 | * [Source on GitHub](https://github.com/borntyping/rust-riemann_client) 6 | * [Packages on Crates.io](https://crates.io/crates/riemann_client) 7 | * [Builds on Travis CI](https://travis-ci.org/borntyping/rust-riemann_client) 8 | 9 | Usage 10 | ----- 11 | 12 | ``` 13 | $ riemann-cli send --service riemann_cli --state ok --metric-d 11 14 | --> { state: "ok" service: "riemann_cli" metric_d: 11 } 15 | <-- { ok: true } 16 | ``` 17 | 18 | ``` 19 | $ riemann-cli query 'service = "riemann_cli"' 20 | HOSTNAME TIME SERVICE METRIC STATE 21 | 1432128319 riemann_cli 11 ok 22 | ``` 23 | 24 | Run `riemann-cli --help` for a list of options availible for the command line interface. 25 | 26 | See the `examples` directory for examples of querying and sending events with the library. 27 | 28 | Development 29 | ----------- 30 | 31 | To build the library alone, without the command line interface and it's dependencies, run `cargo build --lib --no-default-features`. 32 | 33 | The protocol buffer defintion can be updated by replacing `src/proto/mod.proto` with the [latest defintion from the Riemann source](https://raw.githubusercontent.com/aphyr/riemann-java-client/master/src/main/proto/riemann/proto.proto) and running `make`. You will need to have `protoc` and `protoc-gen-rust` installed. `protoc` is provided by the `protobuf-compiler` package on Debian based systems. Instructions for installing `protoc-gen-rust` this are availible in the [README for rust-protobuf](https://github.com/stepancheg/rust-protobuf). 34 | 35 | Licence 36 | ------- 37 | 38 | `riemann_client` is licenced under the [MIT Licence](http://opensource.org/licenses/MIT). 39 | 40 | It was also directly inspired by the Python [riemann-client](http://github.com/borntyping/python-riemann-client) by the same author. 41 | 42 | Authors 43 | ------- 44 | 45 | Written by [Sam Clements](sam@borntyping.co.uk). 46 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | //! A [Riemann](http://riemann.io/) client library and command line interface. 2 | 3 | pub mod client; 4 | /// Layer one: Protobuf implementation generated by `protoc --rust_out`. 5 | pub mod proto; 6 | pub mod transport; 7 | 8 | pub use self::client::Client; 9 | pub use self::utils::{Error, Result}; 10 | 11 | /// Error and From implementations 12 | mod utils { 13 | use std::fmt::{Display, Formatter}; 14 | use std::io::Error as IoError; 15 | 16 | use ::protobuf::error::ProtobufError; 17 | 18 | use super::proto::Query; 19 | 20 | impl<'a> From<&'a str> for Query { 21 | fn from(query_str: &'a str) -> Self { 22 | Query::from(query_str.to_string()) 23 | } 24 | } 25 | 26 | impl From for Query { 27 | fn from(string: String) -> Self { 28 | let mut query = Query::new(); 29 | query.set_string(string); 30 | query 31 | } 32 | } 33 | 34 | #[derive(Debug)] 35 | pub enum Error { 36 | Io(::std::io::Error), 37 | Protobuf(ProtobufError), 38 | Riemann(String), 39 | Cert(webpki::Error), 40 | CACert(String), 41 | Key(String), 42 | TLS(rustls::TLSError), 43 | InvalidDNSNameError(webpki::InvalidDNSNameError), 44 | } 45 | 46 | impl Display for Error { 47 | fn fmt(&self, f: &mut Formatter) -> ::std::fmt::Result { 48 | write!(f, "{}", self) 49 | } 50 | } 51 | 52 | impl From for Error { 53 | fn from(err: IoError) -> Self { 54 | Error::Io(err) 55 | } 56 | } 57 | 58 | impl From for Error { 59 | fn from(err: ProtobufError) -> Self { 60 | Error::Protobuf(err) 61 | } 62 | } 63 | 64 | impl From for Error { 65 | fn from(err: webpki::Error) -> Self { 66 | Error::Cert(err) 67 | } 68 | } 69 | 70 | impl From for Error { 71 | fn from(err: rustls::TLSError) -> Self { 72 | Error::TLS(err) 73 | } 74 | } 75 | 76 | impl From for Error { 77 | fn from(err: webpki::InvalidDNSNameError) -> Self { 78 | Error::InvalidDNSNameError(err) 79 | } 80 | } 81 | 82 | /// Result alias for Riemann client errors 83 | pub type Result = ::std::result::Result; 84 | } 85 | -------------------------------------------------------------------------------- /test_certs/valid_client_key: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIJKQIBAAKCAgEAtqQjF69pDrkmTVyH2GFAGsIim+r6H2rl53h1hTO3cbuYFVrF 3 | YmmlStxTqnU9u3u1qSGdyV/Gc9LgANSOGDcm5G3LO3gI5To1v+O4k9NHSk/9WDep 4 | zR39sc6ikw4zC6TXS2CbhpvXuJ6CilPTTPU8eaIjKM7D2WrIZwa9ilbxo+JbJCgL 5 | cz+HZRb/Zy5ty5xVP/yfRd7ILj+Dr0C4FmvhZxOJ6zAKQZ2O8mcSHh12p3eEivwH 6 | 7WMh+znNurss5uCdTVlA9NKFHpMsLYvwj4cKMxo/aK/vgPrabMwsHdQeX0hIn+OA 7 | vXBLLJVuYfb85T9SvjFzFLj9EJfFcdDouWM/yGxxqqw7I+0o2GO8qpyN3TAtM3It 8 | C8Ejus+I3IlNuT0p0bAy7wvctMBW9a/xBl/8RbM8m+jXE1bRpzM6kcQj0ShZzJC9 9 | x9JjSFd7uxmvMBTZ+XRKyI143/Q0921d42UHiqaQgTWt6DFXEXKsRPJchXNfoDYH 10 | SUoMjn71IYP+A6b9muf3H9o0XV1dVf9SUE9LYlAz5sgv23cG/q4Hgkjukv5K3Xli 11 | EIRNVMearVgHX6T7yqFsaWfUwHiyB7S5aNhEdD9D5MWpLXmUzp0B5nPWWrlwb8z+ 12 | fu78TqVzoCGkF3Nb07+qiwabN0c8vmX5Y9cKYdjW4Do8HbU2f6j5K5lIwQ0CAwEA 13 | AQKCAgA0h3a0XDXqDyROAbvsZuQKDiXoFCgGGzeuYD3kpqAvLNYr5iR5DouEwWOq 14 | 1feAUa9IyqtX/JzWOSNF+dw4aLxd3JokK3zbeOd2nic7FPwfCmyCD9hdby/FEPo/ 15 | M0lJIwrs2gdBKtdbePNwl3VhX/MZxKE6HmXDxWuH/i9Ld4AeM38lIgNRDUeCsp+Y 16 | bIkVk4wNUDn63X1Tl97m68VGZZa5j6wOIY4BmzA+1ZgnYy/6MGzFkIEzLFzcpZ5f 17 | A3CBor57PZ1qDJZO2eNN4j64+Qzc78Km+Fr5DKz/t6VEmvp1SxPgMI2Zbo+gbgYG 18 | VQQdZx4EJ7LClgXq3Mvj1ULp9vqjzOpil06Sal53oigLy7ffSTB0vPRmBs9gRlRk 19 | HXRN6KlArr3LPcdmVw6v8S3Zhx8e6aPDOORhzVn+7zTCNaUpB7cWfIEjFUOCW7Io 20 | xY8AxX9JHccHCxOyzePUpGvhQtm2ZApKLUKxfn1ShvpJIoHBKGvnVBLp0PXdDUe/ 21 | wiS5rG9Dz4siEtj2FK8ux2+kW9Jk97+CAdikYkZLPfz3p6Gvexc91miBBVyQmVfw 22 | DGtyNrCPgYTeq1XWoZ28AGaIoTmIx72KACioP0fXG9e+GcZUTE+ONLATDUqWhkQK 23 | dhje5xYA7aRFKHWhcOjq0vvOxlp+01RtgxWiZaiohXVAR1WS4QKCAQEA3VLL/N4A 24 | rlNas5lgew99nrQCxiDGE0rt6yKYYBTL/VJdWGhrjlFJCirs8DkoCERIKBRdWogn 25 | /c1Gq1Q9nKq8GC+QdGvi2v8HJWLFOoNNB92kHYqDCGQOdGfpigITC8mmBRNWe7CJ 26 | GwbL4dlbq4fCDly4RR1Iq7u2aDRfC1gK3C26tii5F30iiG4T2ezF3X9wnBrLwmu3 27 | tJr9Ud7v6Fwh+fXN9Gje2GNUjhUrcbh2w675aGApo6GCSvM480mg8+/7wzRgcOVq 28 | Zww20eDJfpVCDQ/Xt77pAkMeFcmpch8/8/+0rvBE7R4Y5kWefUy/WXjI56mAhlY8 29 | 95jlXRgTI11+2QKCAQEA00HO+aqqVD18RF89UB+1l+oiyTulJ7Ia7C+wcwvfH/2S 30 | ywLWPEa1rzs+35xXseDX7P1zVrlc1uF36mlRXU41ojFnNe0myoKIgo/EIEjoB0Rc 31 | qJQQ2VFr0bd6ulJMJhSFK0BtS9E/geVl0Wgy60dljoePpbIdk37fPpO1eaIag2MY 32 | 4wialp2hIiR99vgMbYyIz4pB42jQUKqme0VpEUAwjEm/g8z+XKvBwB8mp0hlPsIe 33 | fNQglIkNUcW9TSg4BmroTGKBD+IjecCxfoR2pN9VukX3knQb++KoKbZr8o2khrjs 34 | pD+e9EcpBPjd4FqV7cbEXWtZU3PvZCqT1/MbvUrbVQKCAQEAkPDTJDOjEIcIBEwy 35 | sgSwCMnscyItdZ8BdpZ+YZXdDXXuKaKgpWA4TA9Wge98dwV4l77WcB5wyjavzC3r 36 | 93icm94yZPvuYerYHDS14x7vyHHvM2VtcIZOLQ+MEtRO8s5JClPitDglYeyugqac 37 | 8RWEEXHJP4HxAH56830wrTYoTo8oEnlS1b4eamhkWbhE0EzQS3sE67stYHqL4Rz1 38 | 0h7cJV1DVoeDQQSz8CSPAfeC1530OdWYD1ALCtiD+FfEr1v/bZQUgHrNltSZ5hKn 39 | Al3vFqzEYdIFuHSJ9EzPyiwK7tkL0/EHwp2OQude5sHnIkoGkCgiQlehr6iStMe6 40 | aNOm6QKCAQEAzmmEc8lfN4QEAUIVRE5XPiGU744JpqmNSKyn+SDmV/mJDjatYKOu 41 | LZLzscSuoqyQDYzuvxPKNGKEqlNRHpumJ92hfL1Eo6W6/+a8uNbDbyZKaqSReeTm 42 | NjjR/28d3C88lrASmnvPU3nybBMlfWF7RzIJFtrbrxvNwPTN4hSTV0DiNiJX+UX3 43 | BMcnFMH0Uq13l2D9U9c7gzXaCKQfLq3LQadlKsCG38EqRC+rstM3qYQ+CbWyR69J 44 | hlZwygy8APlAFDJC7GQGSZYPVxDSY/Gbb6+hYEV2ejxSFr+Y5Zuj38ab4TgQdZl5 45 | 6NPI5sdbqsIFZ0nWM4YZp4M6hUuSFPgpKQKCAQB70sCKN9W2AsK7oxgtKPkHdVAg 46 | OGUS6pHbxRuen6HDIuYSY0hY5VpeZ6PmZg4dehd5r+cYw5UJt+7dsy+ElJHKCb+8 47 | kgHYWGIleqinlG3trn3vSvqC7I+0Mj47amwURe2TzNOjeYYkdMnlJP+3w5dc+bA+ 48 | dCpMk5xr9YsWyD0GK+D9dJ2ESJTK3fre93sOc800c74lSuMLvkfEf7nZZI6+B/+m 49 | mtya6xQ0upnE0l3VjLrp1i+uPYeUpWsl+An0iMwma/ih/tDSApaUWVOUx/2JAZdH 50 | YW086ML2wd48d58wk+LS80KrO0AAQLACe/F8bOR+LnLlH5CkrnJmnrNp5Vxg 51 | -----END RSA PRIVATE KEY----- 52 | -------------------------------------------------------------------------------- /src/client/mod.rs: -------------------------------------------------------------------------------- 1 | //! Layer three: An abstract client hiding the TCP/Protobuf layers. 2 | 3 | use std::net::ToSocketAddrs; 4 | use std::time::Duration; 5 | 6 | use super::proto::{Event, Query}; 7 | use super::transport::TCPTransport; 8 | use super::Result; 9 | 10 | mod hostname; 11 | 12 | /// Adds a `set_defaults()` method to `Event` 13 | trait SetDefaults { 14 | fn set_defaults(&mut self) -> Result<()>; 15 | } 16 | 17 | impl SetDefaults for Event { 18 | /// Sets a host and service for the event if they are not set 19 | fn set_defaults(&mut self) -> Result<()> { 20 | if !self.has_host() { 21 | self.set_host(hostname::hostname()?) 22 | } 23 | if !self.has_service() { 24 | self.set_service("riemann_client".to_string()) 25 | } 26 | Ok(()) 27 | } 28 | } 29 | 30 | #[derive(Debug)] 31 | pub struct Client { 32 | pub transport: TCPTransport, 33 | } 34 | 35 | impl Client { 36 | /// Connect to a Riemann server using raw TCP. 37 | pub fn connect(addr: &A) -> Result { 38 | Ok(Client { 39 | transport: TCPTransport::connect(addr)?, 40 | }) 41 | } 42 | 43 | /// Connect to a Riemann server using mTLS over TCP. 44 | pub fn connect_tls( 45 | hostname: &str, 46 | port: u16, 47 | ca_file: &str, 48 | cert_file: &str, 49 | key_file: &str, 50 | ) -> Result { 51 | Ok(Client { 52 | transport: TCPTransport::connect_tls(hostname, port, ca_file, cert_file, key_file)?, 53 | }) 54 | } 55 | 56 | /// Set a read and write timeout for the underlying socket 57 | pub fn set_timeout(&mut self, timeout: Option) -> Result<()> { 58 | self.transport.set_timeout(timeout) 59 | } 60 | 61 | /// Send multiple events, discarding the response if it is not an error. 62 | pub fn events(&mut self, mut events: Vec) -> Result<()> { 63 | // Modify each event in the vector in place 64 | for event in events.iter_mut() { 65 | event.set_defaults()?; 66 | } 67 | 68 | // Send all events in the same message 69 | self.transport.send_events(events)?; 70 | 71 | // A successful response is discarded as it contains no useful information 72 | Ok(()) 73 | } 74 | 75 | /// Wrapper around `.events()` for sending a single `Event`. 76 | pub fn event(&mut self, event: Event) -> Result<()> { 77 | self.events(vec![event]) 78 | } 79 | 80 | /// Send a query and return a sorted list of events matching the query. 81 | pub fn query>(&mut self, query: T) -> Result> { 82 | let response = self.transport.send_query(query.into())?; 83 | 84 | Ok({ 85 | let mut events = Vec::from(response.get_events()); 86 | events.sort_by(|a, b| a.get_service().cmp(b.get_service())); 87 | events 88 | }) 89 | } 90 | } 91 | 92 | #[cfg(test)] 93 | mod test { 94 | use super::super::proto::Event; 95 | use super::hostname::hostname; 96 | use super::SetDefaults; 97 | 98 | #[test] 99 | fn event_defaults() { 100 | let mut event = Event::new(); 101 | event.set_defaults().unwrap(); 102 | 103 | assert_eq!(event.get_service(), "riemann_client".to_string()); 104 | assert_eq!(event.get_host(), hostname().unwrap()); 105 | } 106 | 107 | #[test] 108 | fn event_no_defaults() { 109 | let mut event = Event::new(); 110 | event.set_service("test".to_string()); 111 | event.set_host("test".to_string()); 112 | event.set_defaults().unwrap(); 113 | 114 | assert_eq!(event.get_service(), "test".to_string()); 115 | assert_eq!(event.get_host(), "test".to_string()); 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | //! A command line interface to [Riemann](http://riemann.io/). 2 | //! 3 | //! Requires the optional dependencies (`docopt` and `serde`) that are 4 | //! included by the default feature. 5 | 6 | #![cfg(not(test))] 7 | #![cfg(feature = "default")] 8 | 9 | use docopt::Docopt; 10 | use serde::Deserialize; 11 | 12 | static USAGE: &str = " 13 | Usage: riemann_cli [-H -P ] [--mtls --cafile --cert --key ] send [options] 14 | riemann_cli [-H -P ] [--mtls --cafile --cert --key ] query 15 | riemann_cli --help | --version 16 | 17 | Server options: 18 | -H, --server-host Riemann server hostname [default: localhost]. 19 | -P, --server-port Riemann server port [default: 5555]. 20 | --mtls Connect to Riemann server using mTLS. 21 | --cafile CA certificate filename. 22 | --cert Client certificate filename. 23 | --key Client key certificate filename. 24 | 25 | 26 | Event options: 27 | -T, --time Event timestamp (unix format). 28 | -S, --state Event state. 29 | -s, --service Event service [default: riemann-cli]. 30 | -N, --host Event hostname (defaults to current hostname). 31 | -d, --description Event description. 32 | -t, --tag Event tags (can be used multiple times). 33 | -l, --ttl Event time to live (in seconds). 34 | -a, --attribute Event attributes (key=value pairs, can be used multiple times). 35 | -i, --metric-sint64 Event metric as an integer (using the metric_sint64 field). 36 | -m, --metric-d Event metric as a double (using the metric_d field). 37 | -f, --metric-f Event metric as a float (using the metric_f field). 38 | "; 39 | 40 | #[derive(Deserialize, Debug)] 41 | struct Args { 42 | flag_server_host: String, 43 | flag_server_port: u16, 44 | flag_mtls: Option, 45 | flag_cafile: Option, 46 | flag_cert: Option, 47 | flag_key: Option, 48 | 49 | cmd_send: bool, 50 | flag_time: Option, 51 | flag_state: Option, 52 | flag_service: Option, 53 | flag_host: Option, 54 | flag_description: Option, 55 | flag_tag: Vec, 56 | flag_ttl: Option, 57 | flag_attribute: Option, 58 | flag_metric_sint64: Option, 59 | flag_metric_d: Option, 60 | flag_metric_f: Option, 61 | 62 | cmd_query: bool, 63 | arg_query: String, 64 | 65 | flag_version: bool, 66 | } 67 | 68 | fn main() { 69 | use riemann_client::proto::Attribute; 70 | 71 | let args: Args = Docopt::new(USAGE) 72 | .and_then(|d| d.deserialize()) 73 | .unwrap_or_else(|e| e.exit()); 74 | 75 | if args.flag_version { 76 | println!("riemann_cli v{}", env!("CARGO_PKG_VERSION")); 77 | return; 78 | } 79 | 80 | if args.flag_mtls.is_some() 81 | && (args.flag_cafile.is_none() || args.flag_cert.is_none() || args.flag_key.is_none()) 82 | { 83 | panic!("Args '--cafile', '--cert', '--key' are required using mTLS option.") 84 | } 85 | 86 | let mut client = match args.flag_mtls { 87 | Some(_) => riemann_client::Client::connect_tls( 88 | &args.flag_server_host, 89 | args.flag_server_port, 90 | &args.flag_cafile.unwrap(), 91 | &args.flag_cert.unwrap(), 92 | &args.flag_key.unwrap(), 93 | ) 94 | .unwrap(), 95 | None => { 96 | let addr: (&str, u16) = (&args.flag_server_host, args.flag_server_port); 97 | riemann_client::Client::connect(&addr).unwrap() 98 | } 99 | }; 100 | 101 | if args.cmd_send { 102 | let mut event = riemann_client::proto::Event::new(); 103 | 104 | if let Some(x) = args.flag_time { 105 | event.set_time(x); 106 | } 107 | if let Some(x) = args.flag_state { 108 | event.set_state(x); 109 | } 110 | if let Some(x) = args.flag_service { 111 | event.set_service(x); 112 | } 113 | if let Some(x) = args.flag_host { 114 | event.set_host(x); 115 | } 116 | if let Some(x) = args.flag_description { 117 | event.set_description(x); 118 | } 119 | if let Some(x) = args.flag_ttl { 120 | event.set_ttl(x); 121 | } 122 | if let Some(x) = args.flag_metric_sint64 { 123 | event.set_metric_sint64(x); 124 | } 125 | if let Some(x) = args.flag_metric_d { 126 | event.set_metric_d(x); 127 | } 128 | if let Some(x) = args.flag_metric_f { 129 | event.set_metric_f(x); 130 | } 131 | 132 | if !args.flag_tag.is_empty() { 133 | event.set_tags(protobuf::RepeatedField::from_vec(args.flag_tag)); 134 | } 135 | 136 | if let Some(x) = args.flag_attribute { 137 | let mut vec_attr: Vec = Vec::new(); 138 | let args_attr = x; 139 | let args_attr_split = args_attr.split(','); 140 | for attr in args_attr_split { 141 | let mut res: Vec = attr.split('=').map(|s| s.to_string()).collect(); 142 | let mut at = Attribute::new(); 143 | if let Some(x) = res.pop() { 144 | at.set_value(x) 145 | }; 146 | if let Some(x) = res.pop() { 147 | at.set_key(x) 148 | }; 149 | vec_attr.push(at); 150 | } 151 | event.set_attributes(protobuf::RepeatedField::from_vec(vec_attr)); 152 | } 153 | 154 | println!("--> {{ {:?} }}", event); 155 | let response = client.event(event).unwrap(); 156 | println!("<-- {{ {:?} }}", response); 157 | } else if args.cmd_query { 158 | let events = client.query(args.arg_query).unwrap(); 159 | 160 | println!( 161 | "{:<10} {:<10} {:<55} {:<10} {:<10}", 162 | "HOSTNAME", "TIME", "SERVICE", "METRIC", "STATE" 163 | ); 164 | 165 | for event in events { 166 | println!( 167 | "{:<10} {:<10} {:<55} {:<10} {:<10}", 168 | event.get_host(), 169 | event.get_time(), 170 | event.get_service(), 171 | event.get_metric_f(), 172 | event.get_state() 173 | ); 174 | } 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /src/transport/mod.rs: -------------------------------------------------------------------------------- 1 | //! Layer two: Protobuf transport over TCP. 2 | 3 | use std::net::{TcpStream, ToSocketAddrs}; 4 | use std::time::Duration; 5 | 6 | use ::protobuf::{CodedInputStream, Message}; 7 | 8 | use super::proto::{Event, Msg, Query}; 9 | use super::utils::{Error, Result}; 10 | 11 | use std::sync::Arc; 12 | 13 | use std::fs::File; 14 | use std::io::BufReader; 15 | use std::io::Read; 16 | use std::io::Write; 17 | 18 | pub struct TCPTransport { 19 | stream: TcpStream, 20 | tls_sess: Option, 21 | } 22 | 23 | impl TCPTransport { 24 | pub fn connect(addr: &A) -> Result { 25 | Ok(TCPTransport { 26 | stream: TcpStream::connect(addr)?, 27 | tls_sess: None, 28 | }) 29 | } 30 | 31 | pub fn connect_tls( 32 | hostname: &str, 33 | port: u16, 34 | ca_file: &str, 35 | cert_file: &str, 36 | key_file: &str, 37 | ) -> Result { 38 | let addr = (hostname, port); 39 | let mut config = rustls::ClientConfig::new(); 40 | config 41 | .root_store 42 | .add( 43 | load_certs(ca_file) 44 | .or_else(|e| match e { 45 | Error::Io(e) => Err(Error::CACert(format!( 46 | "Fail to load CACert file ({}): {}", 47 | ca_file, e 48 | ))), 49 | _ => unreachable!("CAcert issue"), 50 | })? 51 | .get(0) 52 | .ok_or_else(|| { 53 | Error::CACert(format!("Certificate file ({}) probably empty", ca_file)) 54 | })?, 55 | ) 56 | .map_err(|e| Error::CACert(format!("Certificate format error: {}", e)))?; 57 | 58 | config.set_single_client_cert( 59 | load_certs(cert_file).or_else(|e| match e { 60 | Error::Io(e) => Err(Error::Key(format!( 61 | "Fail to load client cert file ({}): {}", 62 | cert_file, e 63 | ))), 64 | _ => unreachable!("Client cert issue"), 65 | })?, 66 | load_private_key(key_file).or_else(|e| match e { 67 | Error::Io(e) => Err(Error::Key(format!( 68 | "Fail to load key file ({}): {}", 69 | key_file, e 70 | ))), 71 | _ => unreachable!("Key issue"), 72 | })?, 73 | )?; 74 | 75 | let dns_name = webpki::DNSNameRef::try_from_ascii_str(hostname)?; 76 | let sess = rustls::ClientSession::new(&Arc::new(config), dns_name); 77 | let stream = TcpStream::connect(addr)?; 78 | Ok(TCPTransport { 79 | stream, 80 | tls_sess: Some(sess), 81 | }) 82 | } 83 | 84 | pub fn set_timeout(&mut self, timeout: Option) -> Result<()> { 85 | self.stream.set_write_timeout(timeout)?; 86 | self.stream.set_read_timeout(timeout)?; 87 | Ok(()) 88 | } 89 | 90 | pub fn send_msg_encryption_wrapper(&mut self, msg: Msg) -> Result { 91 | match self.tls_sess.as_mut() { 92 | Some(_) => send_msg( 93 | rustls::Stream::new(self.tls_sess.as_mut().unwrap(), &mut self.stream), 94 | msg, 95 | ), 96 | None => send_msg(&mut self.stream, msg), 97 | } 98 | } 99 | 100 | pub fn send_events(&mut self, events: Vec) -> Result { 101 | self.send_msg_encryption_wrapper({ 102 | let mut msg = Msg::new(); 103 | msg.set_events(::protobuf::RepeatedField::from_vec(events)); 104 | msg 105 | }) 106 | } 107 | 108 | pub fn send_query(&mut self, query: Query) -> Result { 109 | self.send_msg_encryption_wrapper({ 110 | let mut msg = Msg::new(); 111 | msg.set_query(query); 112 | msg 113 | }) 114 | } 115 | } 116 | 117 | impl ::std::fmt::Debug for TCPTransport { 118 | fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { 119 | write!(f, "TCPTransport {{ addr: {:?} }}", self.stream.peer_addr()) 120 | } 121 | } 122 | 123 | fn load_certs(filename: &str) -> Result> { 124 | let certfile = File::open(filename)?; 125 | let mut reader = BufReader::new(certfile); 126 | Ok(rustls_pemfile::certs(&mut reader)? 127 | .iter() 128 | .map(|v| rustls::Certificate(v.clone())) 129 | .collect()) 130 | } 131 | 132 | fn load_private_key(filename: &str) -> Result { 133 | let keyfile = File::open(filename)?; 134 | let mut reader = BufReader::new(keyfile); 135 | 136 | loop { 137 | match rustls_pemfile::read_one(&mut reader)? { 138 | Some(rustls_pemfile::Item::RSAKey(key)) => return Ok(rustls::PrivateKey(key)), 139 | 140 | Some(rustls_pemfile::Item::PKCS8Key(key)) => return Ok(rustls::PrivateKey(key)), 141 | None => break, 142 | _ => {} 143 | } 144 | } 145 | 146 | Err(Error::Key("Key not found".to_string())) 147 | } 148 | 149 | fn send_msg(mut stream: T, msg: Msg) -> Result { 150 | // Prepare the message for writing. 151 | let size = msg.compute_size(); 152 | let bytes = msg.write_to_bytes()?; 153 | 154 | assert!( 155 | size == bytes.len() as u32, 156 | "Message computed size ({}) and encoded length ({}) do not \ 157 | match, you are going to have a bad day.", 158 | size, 159 | bytes.len() 160 | ); 161 | 162 | // Write the message size as a big-endian unsigned integer. 163 | stream.write_all(&[((size >> 24) & 0xFF) as u8])?; 164 | stream.write_all(&[((size >> 16) & 0xFF) as u8])?; 165 | stream.write_all(&[((size >> 8) & 0xFF) as u8])?; 166 | stream.write_all(&[((size) & 0xFF) as u8])?; 167 | 168 | // Write the rest of the message. 169 | stream.write_all(&bytes)?; 170 | stream.flush()?; 171 | 172 | // CodedInputStream is used for the `read_raw_byte(s)` methods 173 | let mut input_stream = CodedInputStream::new(&mut stream); 174 | 175 | // Read the message size as a big-endian 32 bit unsigned integer. 176 | let mut size: u32 = 0; 177 | size += (input_stream.read_raw_byte()? as u32) << 24; 178 | size += (input_stream.read_raw_byte()? as u32) << 16; 179 | size += (input_stream.read_raw_byte()? as u32) << 8; 180 | size += input_stream.read_raw_byte()? as u32; 181 | 182 | // Read the expected bytes and parse them as a message. 183 | let bytes = input_stream.read_raw_bytes(size)?; 184 | let msg: Msg = protobuf::Message::parse_from_bytes(&bytes)?; 185 | 186 | // If the message has set `ok: false`, transform it into an `Err` 187 | if msg.get_ok() { 188 | Ok(msg) 189 | } else { 190 | Err(Error::Riemann(msg.get_error().to_string())) 191 | } 192 | } 193 | 194 | #[cfg(test)] 195 | mod tests { 196 | use super::*; 197 | 198 | #[test] 199 | fn test_load_valid_cert() { 200 | let mut config = rustls::ClientConfig::new(); 201 | assert_eq!( 202 | config.root_store.add( 203 | load_certs("test_certs/valid_cert.pem") 204 | .unwrap() 205 | .get(0) 206 | .unwrap(), 207 | ), 208 | Ok(()), 209 | ); 210 | } 211 | 212 | #[test] 213 | #[should_panic( 214 | expected = "called `Result::unwrap()` on an `Err` value: Io(Os { code: 2, kind: NotFound, message: \"No such file or directory\" }" 215 | )] 216 | fn test_load_missing_cert() { 217 | let mut config = rustls::ClientConfig::new(); 218 | assert_eq!( 219 | config.root_store.add( 220 | load_certs("test_certs/missing_cert.pem") 221 | .unwrap() 222 | .get(0) 223 | .unwrap(), 224 | ), 225 | Ok(()), 226 | ); 227 | } 228 | 229 | #[test] 230 | #[should_panic(expected = "called `Option::unwrap()` on a `None` value")] 231 | fn test_load_empty_cert() { 232 | let mut config = rustls::ClientConfig::new(); 233 | assert_eq!( 234 | config.root_store.add( 235 | load_certs("test_certs/empty_cert.pem") 236 | .unwrap() 237 | .get(0) 238 | .unwrap(), 239 | ), 240 | Ok(()), 241 | ); 242 | } 243 | 244 | #[test] 245 | fn test_load_invalid_cert() { 246 | let mut config = rustls::ClientConfig::new(); 247 | assert_eq!( 248 | config.root_store.add( 249 | load_certs("test_certs/invalid_cert.pem") 250 | .unwrap() 251 | .get(0) 252 | .unwrap(), 253 | ), 254 | Err(webpki::Error::BadDER), 255 | ); 256 | } 257 | 258 | #[test] 259 | fn test_load_valid_key() { 260 | let mut config = rustls::ClientConfig::new(); 261 | assert_eq!( 262 | config.set_single_client_cert( 263 | load_certs("test_certs/valid_client_cert.pem").unwrap(), 264 | load_private_key("test_certs/valid_client_key").unwrap(), 265 | ), 266 | Ok(()) 267 | ); 268 | } 269 | 270 | #[test] 271 | #[should_panic( 272 | expected = "called `Result::unwrap()` on an `Err` value: Key(\"Key not found\")" 273 | )] 274 | fn test_load_empty_key() { 275 | let mut config = rustls::ClientConfig::new(); 276 | assert_eq!( 277 | config.set_single_client_cert( 278 | load_certs("test_certs/valid_client_cert.pem").unwrap(), 279 | load_private_key("test_certs/empty_client_key").unwrap(), 280 | ), 281 | Ok(()) 282 | ); 283 | } 284 | 285 | #[test] 286 | fn test_load_invalid_key() { 287 | let mut config = rustls::ClientConfig::new(); 288 | assert_eq!( 289 | config.set_single_client_cert( 290 | load_certs("test_certs/valid_client_cert.pem").unwrap(), 291 | load_private_key("test_certs/invalid_client_key").unwrap(), 292 | ), 293 | Err(rustls::TLSError::General("invalid private key".to_string())) 294 | ); 295 | } 296 | } 297 | -------------------------------------------------------------------------------- /src/proto/mod_pb.rs: -------------------------------------------------------------------------------- 1 | // This file is generated by rust-protobuf 2.20.0. Do not edit 2 | // @generated 3 | 4 | // https://github.com/rust-lang/rust-clippy/issues/702 5 | #![allow(unknown_lints)] 6 | #![allow(clippy::all)] 7 | 8 | #![allow(unused_attributes)] 9 | #![rustfmt::skip] 10 | 11 | #![allow(box_pointers)] 12 | #![allow(dead_code)] 13 | #![allow(missing_docs)] 14 | #![allow(non_camel_case_types)] 15 | #![allow(non_snake_case)] 16 | #![allow(non_upper_case_globals)] 17 | #![allow(trivial_casts)] 18 | #![allow(unused_imports)] 19 | #![allow(unused_results)] 20 | //! Generated file from `src/proto/mod.proto` 21 | 22 | /// Generated files are compatible only with the same version 23 | /// of protobuf runtime. 24 | // const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_20_0; 25 | 26 | #[derive(PartialEq,Clone,Default)] 27 | pub struct State { 28 | // message fields 29 | time: ::std::option::Option, 30 | state: ::protobuf::SingularField<::std::string::String>, 31 | service: ::protobuf::SingularField<::std::string::String>, 32 | host: ::protobuf::SingularField<::std::string::String>, 33 | description: ::protobuf::SingularField<::std::string::String>, 34 | once: ::std::option::Option, 35 | pub tags: ::protobuf::RepeatedField<::std::string::String>, 36 | ttl: ::std::option::Option, 37 | // special fields 38 | pub unknown_fields: ::protobuf::UnknownFields, 39 | pub cached_size: ::protobuf::CachedSize, 40 | } 41 | 42 | impl<'a> ::std::default::Default for &'a State { 43 | fn default() -> &'a State { 44 | ::default_instance() 45 | } 46 | } 47 | 48 | impl State { 49 | pub fn new() -> State { 50 | ::std::default::Default::default() 51 | } 52 | 53 | // optional int64 time = 1; 54 | 55 | 56 | pub fn get_time(&self) -> i64 { 57 | self.time.unwrap_or(0) 58 | } 59 | pub fn clear_time(&mut self) { 60 | self.time = ::std::option::Option::None; 61 | } 62 | 63 | pub fn has_time(&self) -> bool { 64 | self.time.is_some() 65 | } 66 | 67 | // Param is passed by value, moved 68 | pub fn set_time(&mut self, v: i64) { 69 | self.time = ::std::option::Option::Some(v); 70 | } 71 | 72 | // optional string state = 2; 73 | 74 | 75 | pub fn get_state(&self) -> &str { 76 | match self.state.as_ref() { 77 | Some(v) => &v, 78 | None => "", 79 | } 80 | } 81 | pub fn clear_state(&mut self) { 82 | self.state.clear(); 83 | } 84 | 85 | pub fn has_state(&self) -> bool { 86 | self.state.is_some() 87 | } 88 | 89 | // Param is passed by value, moved 90 | pub fn set_state(&mut self, v: ::std::string::String) { 91 | self.state = ::protobuf::SingularField::some(v); 92 | } 93 | 94 | // Mutable pointer to the field. 95 | // If field is not initialized, it is initialized with default value first. 96 | pub fn mut_state(&mut self) -> &mut ::std::string::String { 97 | if self.state.is_none() { 98 | self.state.set_default(); 99 | } 100 | self.state.as_mut().unwrap() 101 | } 102 | 103 | // Take field 104 | pub fn take_state(&mut self) -> ::std::string::String { 105 | self.state.take().unwrap_or_else(|| ::std::string::String::new()) 106 | } 107 | 108 | // optional string service = 3; 109 | 110 | 111 | pub fn get_service(&self) -> &str { 112 | match self.service.as_ref() { 113 | Some(v) => &v, 114 | None => "", 115 | } 116 | } 117 | pub fn clear_service(&mut self) { 118 | self.service.clear(); 119 | } 120 | 121 | pub fn has_service(&self) -> bool { 122 | self.service.is_some() 123 | } 124 | 125 | // Param is passed by value, moved 126 | pub fn set_service(&mut self, v: ::std::string::String) { 127 | self.service = ::protobuf::SingularField::some(v); 128 | } 129 | 130 | // Mutable pointer to the field. 131 | // If field is not initialized, it is initialized with default value first. 132 | pub fn mut_service(&mut self) -> &mut ::std::string::String { 133 | if self.service.is_none() { 134 | self.service.set_default(); 135 | } 136 | self.service.as_mut().unwrap() 137 | } 138 | 139 | // Take field 140 | pub fn take_service(&mut self) -> ::std::string::String { 141 | self.service.take().unwrap_or_else(|| ::std::string::String::new()) 142 | } 143 | 144 | // optional string host = 4; 145 | 146 | 147 | pub fn get_host(&self) -> &str { 148 | match self.host.as_ref() { 149 | Some(v) => &v, 150 | None => "", 151 | } 152 | } 153 | pub fn clear_host(&mut self) { 154 | self.host.clear(); 155 | } 156 | 157 | pub fn has_host(&self) -> bool { 158 | self.host.is_some() 159 | } 160 | 161 | // Param is passed by value, moved 162 | pub fn set_host(&mut self, v: ::std::string::String) { 163 | self.host = ::protobuf::SingularField::some(v); 164 | } 165 | 166 | // Mutable pointer to the field. 167 | // If field is not initialized, it is initialized with default value first. 168 | pub fn mut_host(&mut self) -> &mut ::std::string::String { 169 | if self.host.is_none() { 170 | self.host.set_default(); 171 | } 172 | self.host.as_mut().unwrap() 173 | } 174 | 175 | // Take field 176 | pub fn take_host(&mut self) -> ::std::string::String { 177 | self.host.take().unwrap_or_else(|| ::std::string::String::new()) 178 | } 179 | 180 | // optional string description = 5; 181 | 182 | 183 | pub fn get_description(&self) -> &str { 184 | match self.description.as_ref() { 185 | Some(v) => &v, 186 | None => "", 187 | } 188 | } 189 | pub fn clear_description(&mut self) { 190 | self.description.clear(); 191 | } 192 | 193 | pub fn has_description(&self) -> bool { 194 | self.description.is_some() 195 | } 196 | 197 | // Param is passed by value, moved 198 | pub fn set_description(&mut self, v: ::std::string::String) { 199 | self.description = ::protobuf::SingularField::some(v); 200 | } 201 | 202 | // Mutable pointer to the field. 203 | // If field is not initialized, it is initialized with default value first. 204 | pub fn mut_description(&mut self) -> &mut ::std::string::String { 205 | if self.description.is_none() { 206 | self.description.set_default(); 207 | } 208 | self.description.as_mut().unwrap() 209 | } 210 | 211 | // Take field 212 | pub fn take_description(&mut self) -> ::std::string::String { 213 | self.description.take().unwrap_or_else(|| ::std::string::String::new()) 214 | } 215 | 216 | // optional bool once = 6; 217 | 218 | 219 | pub fn get_once(&self) -> bool { 220 | self.once.unwrap_or(false) 221 | } 222 | pub fn clear_once(&mut self) { 223 | self.once = ::std::option::Option::None; 224 | } 225 | 226 | pub fn has_once(&self) -> bool { 227 | self.once.is_some() 228 | } 229 | 230 | // Param is passed by value, moved 231 | pub fn set_once(&mut self, v: bool) { 232 | self.once = ::std::option::Option::Some(v); 233 | } 234 | 235 | // repeated string tags = 7; 236 | 237 | 238 | pub fn get_tags(&self) -> &[::std::string::String] { 239 | &self.tags 240 | } 241 | pub fn clear_tags(&mut self) { 242 | self.tags.clear(); 243 | } 244 | 245 | // Param is passed by value, moved 246 | pub fn set_tags(&mut self, v: ::protobuf::RepeatedField<::std::string::String>) { 247 | self.tags = v; 248 | } 249 | 250 | // Mutable pointer to the field. 251 | pub fn mut_tags(&mut self) -> &mut ::protobuf::RepeatedField<::std::string::String> { 252 | &mut self.tags 253 | } 254 | 255 | // Take field 256 | pub fn take_tags(&mut self) -> ::protobuf::RepeatedField<::std::string::String> { 257 | ::std::mem::replace(&mut self.tags, ::protobuf::RepeatedField::new()) 258 | } 259 | 260 | // optional float ttl = 8; 261 | 262 | 263 | pub fn get_ttl(&self) -> f32 { 264 | self.ttl.unwrap_or(0.) 265 | } 266 | pub fn clear_ttl(&mut self) { 267 | self.ttl = ::std::option::Option::None; 268 | } 269 | 270 | pub fn has_ttl(&self) -> bool { 271 | self.ttl.is_some() 272 | } 273 | 274 | // Param is passed by value, moved 275 | pub fn set_ttl(&mut self, v: f32) { 276 | self.ttl = ::std::option::Option::Some(v); 277 | } 278 | } 279 | 280 | impl ::protobuf::Message for State { 281 | fn is_initialized(&self) -> bool { 282 | true 283 | } 284 | 285 | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { 286 | while !is.eof()? { 287 | let (field_number, wire_type) = is.read_tag_unpack()?; 288 | match field_number { 289 | 1 => { 290 | if wire_type != ::protobuf::wire_format::WireTypeVarint { 291 | return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); 292 | } 293 | let tmp = is.read_int64()?; 294 | self.time = ::std::option::Option::Some(tmp); 295 | }, 296 | 2 => { 297 | ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.state)?; 298 | }, 299 | 3 => { 300 | ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.service)?; 301 | }, 302 | 4 => { 303 | ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.host)?; 304 | }, 305 | 5 => { 306 | ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.description)?; 307 | }, 308 | 6 => { 309 | if wire_type != ::protobuf::wire_format::WireTypeVarint { 310 | return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); 311 | } 312 | let tmp = is.read_bool()?; 313 | self.once = ::std::option::Option::Some(tmp); 314 | }, 315 | 7 => { 316 | ::protobuf::rt::read_repeated_string_into(wire_type, is, &mut self.tags)?; 317 | }, 318 | 8 => { 319 | if wire_type != ::protobuf::wire_format::WireTypeFixed32 { 320 | return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); 321 | } 322 | let tmp = is.read_float()?; 323 | self.ttl = ::std::option::Option::Some(tmp); 324 | }, 325 | _ => { 326 | ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; 327 | }, 328 | }; 329 | } 330 | ::std::result::Result::Ok(()) 331 | } 332 | 333 | // Compute sizes of nested messages 334 | #[allow(unused_variables)] 335 | fn compute_size(&self) -> u32 { 336 | let mut my_size = 0; 337 | if let Some(v) = self.time { 338 | my_size += ::protobuf::rt::value_size(1, v, ::protobuf::wire_format::WireTypeVarint); 339 | } 340 | if let Some(ref v) = self.state.as_ref() { 341 | my_size += ::protobuf::rt::string_size(2, &v); 342 | } 343 | if let Some(ref v) = self.service.as_ref() { 344 | my_size += ::protobuf::rt::string_size(3, &v); 345 | } 346 | if let Some(ref v) = self.host.as_ref() { 347 | my_size += ::protobuf::rt::string_size(4, &v); 348 | } 349 | if let Some(ref v) = self.description.as_ref() { 350 | my_size += ::protobuf::rt::string_size(5, &v); 351 | } 352 | if let Some(v) = self.once { 353 | my_size += 2; 354 | } 355 | for value in &self.tags { 356 | my_size += ::protobuf::rt::string_size(7, &value); 357 | }; 358 | if let Some(v) = self.ttl { 359 | my_size += 5; 360 | } 361 | my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); 362 | self.cached_size.set(my_size); 363 | my_size 364 | } 365 | 366 | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { 367 | if let Some(v) = self.time { 368 | os.write_int64(1, v)?; 369 | } 370 | if let Some(ref v) = self.state.as_ref() { 371 | os.write_string(2, &v)?; 372 | } 373 | if let Some(ref v) = self.service.as_ref() { 374 | os.write_string(3, &v)?; 375 | } 376 | if let Some(ref v) = self.host.as_ref() { 377 | os.write_string(4, &v)?; 378 | } 379 | if let Some(ref v) = self.description.as_ref() { 380 | os.write_string(5, &v)?; 381 | } 382 | if let Some(v) = self.once { 383 | os.write_bool(6, v)?; 384 | } 385 | for v in &self.tags { 386 | os.write_string(7, &v)?; 387 | }; 388 | if let Some(v) = self.ttl { 389 | os.write_float(8, v)?; 390 | } 391 | os.write_unknown_fields(self.get_unknown_fields())?; 392 | ::std::result::Result::Ok(()) 393 | } 394 | 395 | fn get_cached_size(&self) -> u32 { 396 | self.cached_size.get() 397 | } 398 | 399 | fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { 400 | &self.unknown_fields 401 | } 402 | 403 | fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { 404 | &mut self.unknown_fields 405 | } 406 | 407 | fn as_any(&self) -> &dyn (::std::any::Any) { 408 | self as &dyn (::std::any::Any) 409 | } 410 | fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { 411 | self as &mut dyn (::std::any::Any) 412 | } 413 | fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { 414 | self 415 | } 416 | 417 | fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { 418 | Self::descriptor_static() 419 | } 420 | 421 | fn new() -> State { 422 | State::new() 423 | } 424 | 425 | fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { 426 | static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; 427 | descriptor.get(|| { 428 | let mut fields = ::std::vec::Vec::new(); 429 | fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeInt64>( 430 | "time", 431 | |m: &State| { &m.time }, 432 | |m: &mut State| { &mut m.time }, 433 | )); 434 | fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( 435 | "state", 436 | |m: &State| { &m.state }, 437 | |m: &mut State| { &mut m.state }, 438 | )); 439 | fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( 440 | "service", 441 | |m: &State| { &m.service }, 442 | |m: &mut State| { &mut m.service }, 443 | )); 444 | fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( 445 | "host", 446 | |m: &State| { &m.host }, 447 | |m: &mut State| { &mut m.host }, 448 | )); 449 | fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( 450 | "description", 451 | |m: &State| { &m.description }, 452 | |m: &mut State| { &mut m.description }, 453 | )); 454 | fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeBool>( 455 | "once", 456 | |m: &State| { &m.once }, 457 | |m: &mut State| { &mut m.once }, 458 | )); 459 | fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( 460 | "tags", 461 | |m: &State| { &m.tags }, 462 | |m: &mut State| { &mut m.tags }, 463 | )); 464 | fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeFloat>( 465 | "ttl", 466 | |m: &State| { &m.ttl }, 467 | |m: &mut State| { &mut m.ttl }, 468 | )); 469 | ::protobuf::reflect::MessageDescriptor::new_pb_name::( 470 | "State", 471 | fields, 472 | file_descriptor_proto() 473 | ) 474 | }) 475 | } 476 | 477 | fn default_instance() -> &'static State { 478 | static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; 479 | instance.get(State::new) 480 | } 481 | } 482 | 483 | impl ::protobuf::Clear for State { 484 | fn clear(&mut self) { 485 | self.time = ::std::option::Option::None; 486 | self.state.clear(); 487 | self.service.clear(); 488 | self.host.clear(); 489 | self.description.clear(); 490 | self.once = ::std::option::Option::None; 491 | self.tags.clear(); 492 | self.ttl = ::std::option::Option::None; 493 | self.unknown_fields.clear(); 494 | } 495 | } 496 | 497 | impl ::std::fmt::Debug for State { 498 | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { 499 | ::protobuf::text_format::fmt(self, f) 500 | } 501 | } 502 | 503 | impl ::protobuf::reflect::ProtobufValue for State { 504 | fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { 505 | ::protobuf::reflect::ReflectValueRef::Message(self) 506 | } 507 | } 508 | 509 | #[derive(PartialEq,Clone,Default)] 510 | pub struct Event { 511 | // message fields 512 | time: ::std::option::Option, 513 | state: ::protobuf::SingularField<::std::string::String>, 514 | service: ::protobuf::SingularField<::std::string::String>, 515 | host: ::protobuf::SingularField<::std::string::String>, 516 | description: ::protobuf::SingularField<::std::string::String>, 517 | pub tags: ::protobuf::RepeatedField<::std::string::String>, 518 | ttl: ::std::option::Option, 519 | pub attributes: ::protobuf::RepeatedField, 520 | time_micros: ::std::option::Option, 521 | metric_sint64: ::std::option::Option, 522 | metric_d: ::std::option::Option, 523 | metric_f: ::std::option::Option, 524 | // special fields 525 | pub unknown_fields: ::protobuf::UnknownFields, 526 | pub cached_size: ::protobuf::CachedSize, 527 | } 528 | 529 | impl<'a> ::std::default::Default for &'a Event { 530 | fn default() -> &'a Event { 531 | ::default_instance() 532 | } 533 | } 534 | 535 | impl Event { 536 | pub fn new() -> Event { 537 | ::std::default::Default::default() 538 | } 539 | 540 | // optional int64 time = 1; 541 | 542 | 543 | pub fn get_time(&self) -> i64 { 544 | self.time.unwrap_or(0) 545 | } 546 | pub fn clear_time(&mut self) { 547 | self.time = ::std::option::Option::None; 548 | } 549 | 550 | pub fn has_time(&self) -> bool { 551 | self.time.is_some() 552 | } 553 | 554 | // Param is passed by value, moved 555 | pub fn set_time(&mut self, v: i64) { 556 | self.time = ::std::option::Option::Some(v); 557 | } 558 | 559 | // optional string state = 2; 560 | 561 | 562 | pub fn get_state(&self) -> &str { 563 | match self.state.as_ref() { 564 | Some(v) => &v, 565 | None => "", 566 | } 567 | } 568 | pub fn clear_state(&mut self) { 569 | self.state.clear(); 570 | } 571 | 572 | pub fn has_state(&self) -> bool { 573 | self.state.is_some() 574 | } 575 | 576 | // Param is passed by value, moved 577 | pub fn set_state(&mut self, v: ::std::string::String) { 578 | self.state = ::protobuf::SingularField::some(v); 579 | } 580 | 581 | // Mutable pointer to the field. 582 | // If field is not initialized, it is initialized with default value first. 583 | pub fn mut_state(&mut self) -> &mut ::std::string::String { 584 | if self.state.is_none() { 585 | self.state.set_default(); 586 | } 587 | self.state.as_mut().unwrap() 588 | } 589 | 590 | // Take field 591 | pub fn take_state(&mut self) -> ::std::string::String { 592 | self.state.take().unwrap_or_else(|| ::std::string::String::new()) 593 | } 594 | 595 | // optional string service = 3; 596 | 597 | 598 | pub fn get_service(&self) -> &str { 599 | match self.service.as_ref() { 600 | Some(v) => &v, 601 | None => "", 602 | } 603 | } 604 | pub fn clear_service(&mut self) { 605 | self.service.clear(); 606 | } 607 | 608 | pub fn has_service(&self) -> bool { 609 | self.service.is_some() 610 | } 611 | 612 | // Param is passed by value, moved 613 | pub fn set_service(&mut self, v: ::std::string::String) { 614 | self.service = ::protobuf::SingularField::some(v); 615 | } 616 | 617 | // Mutable pointer to the field. 618 | // If field is not initialized, it is initialized with default value first. 619 | pub fn mut_service(&mut self) -> &mut ::std::string::String { 620 | if self.service.is_none() { 621 | self.service.set_default(); 622 | } 623 | self.service.as_mut().unwrap() 624 | } 625 | 626 | // Take field 627 | pub fn take_service(&mut self) -> ::std::string::String { 628 | self.service.take().unwrap_or_else(|| ::std::string::String::new()) 629 | } 630 | 631 | // optional string host = 4; 632 | 633 | 634 | pub fn get_host(&self) -> &str { 635 | match self.host.as_ref() { 636 | Some(v) => &v, 637 | None => "", 638 | } 639 | } 640 | pub fn clear_host(&mut self) { 641 | self.host.clear(); 642 | } 643 | 644 | pub fn has_host(&self) -> bool { 645 | self.host.is_some() 646 | } 647 | 648 | // Param is passed by value, moved 649 | pub fn set_host(&mut self, v: ::std::string::String) { 650 | self.host = ::protobuf::SingularField::some(v); 651 | } 652 | 653 | // Mutable pointer to the field. 654 | // If field is not initialized, it is initialized with default value first. 655 | pub fn mut_host(&mut self) -> &mut ::std::string::String { 656 | if self.host.is_none() { 657 | self.host.set_default(); 658 | } 659 | self.host.as_mut().unwrap() 660 | } 661 | 662 | // Take field 663 | pub fn take_host(&mut self) -> ::std::string::String { 664 | self.host.take().unwrap_or_else(|| ::std::string::String::new()) 665 | } 666 | 667 | // optional string description = 5; 668 | 669 | 670 | pub fn get_description(&self) -> &str { 671 | match self.description.as_ref() { 672 | Some(v) => &v, 673 | None => "", 674 | } 675 | } 676 | pub fn clear_description(&mut self) { 677 | self.description.clear(); 678 | } 679 | 680 | pub fn has_description(&self) -> bool { 681 | self.description.is_some() 682 | } 683 | 684 | // Param is passed by value, moved 685 | pub fn set_description(&mut self, v: ::std::string::String) { 686 | self.description = ::protobuf::SingularField::some(v); 687 | } 688 | 689 | // Mutable pointer to the field. 690 | // If field is not initialized, it is initialized with default value first. 691 | pub fn mut_description(&mut self) -> &mut ::std::string::String { 692 | if self.description.is_none() { 693 | self.description.set_default(); 694 | } 695 | self.description.as_mut().unwrap() 696 | } 697 | 698 | // Take field 699 | pub fn take_description(&mut self) -> ::std::string::String { 700 | self.description.take().unwrap_or_else(|| ::std::string::String::new()) 701 | } 702 | 703 | // repeated string tags = 7; 704 | 705 | 706 | pub fn get_tags(&self) -> &[::std::string::String] { 707 | &self.tags 708 | } 709 | pub fn clear_tags(&mut self) { 710 | self.tags.clear(); 711 | } 712 | 713 | // Param is passed by value, moved 714 | pub fn set_tags(&mut self, v: ::protobuf::RepeatedField<::std::string::String>) { 715 | self.tags = v; 716 | } 717 | 718 | // Mutable pointer to the field. 719 | pub fn mut_tags(&mut self) -> &mut ::protobuf::RepeatedField<::std::string::String> { 720 | &mut self.tags 721 | } 722 | 723 | // Take field 724 | pub fn take_tags(&mut self) -> ::protobuf::RepeatedField<::std::string::String> { 725 | ::std::mem::replace(&mut self.tags, ::protobuf::RepeatedField::new()) 726 | } 727 | 728 | // optional float ttl = 8; 729 | 730 | 731 | pub fn get_ttl(&self) -> f32 { 732 | self.ttl.unwrap_or(0.) 733 | } 734 | pub fn clear_ttl(&mut self) { 735 | self.ttl = ::std::option::Option::None; 736 | } 737 | 738 | pub fn has_ttl(&self) -> bool { 739 | self.ttl.is_some() 740 | } 741 | 742 | // Param is passed by value, moved 743 | pub fn set_ttl(&mut self, v: f32) { 744 | self.ttl = ::std::option::Option::Some(v); 745 | } 746 | 747 | // repeated .Attribute attributes = 9; 748 | 749 | 750 | pub fn get_attributes(&self) -> &[Attribute] { 751 | &self.attributes 752 | } 753 | pub fn clear_attributes(&mut self) { 754 | self.attributes.clear(); 755 | } 756 | 757 | // Param is passed by value, moved 758 | pub fn set_attributes(&mut self, v: ::protobuf::RepeatedField) { 759 | self.attributes = v; 760 | } 761 | 762 | // Mutable pointer to the field. 763 | pub fn mut_attributes(&mut self) -> &mut ::protobuf::RepeatedField { 764 | &mut self.attributes 765 | } 766 | 767 | // Take field 768 | pub fn take_attributes(&mut self) -> ::protobuf::RepeatedField { 769 | ::std::mem::replace(&mut self.attributes, ::protobuf::RepeatedField::new()) 770 | } 771 | 772 | // optional int64 time_micros = 10; 773 | 774 | 775 | pub fn get_time_micros(&self) -> i64 { 776 | self.time_micros.unwrap_or(0) 777 | } 778 | pub fn clear_time_micros(&mut self) { 779 | self.time_micros = ::std::option::Option::None; 780 | } 781 | 782 | pub fn has_time_micros(&self) -> bool { 783 | self.time_micros.is_some() 784 | } 785 | 786 | // Param is passed by value, moved 787 | pub fn set_time_micros(&mut self, v: i64) { 788 | self.time_micros = ::std::option::Option::Some(v); 789 | } 790 | 791 | // optional sint64 metric_sint64 = 13; 792 | 793 | 794 | pub fn get_metric_sint64(&self) -> i64 { 795 | self.metric_sint64.unwrap_or(0) 796 | } 797 | pub fn clear_metric_sint64(&mut self) { 798 | self.metric_sint64 = ::std::option::Option::None; 799 | } 800 | 801 | pub fn has_metric_sint64(&self) -> bool { 802 | self.metric_sint64.is_some() 803 | } 804 | 805 | // Param is passed by value, moved 806 | pub fn set_metric_sint64(&mut self, v: i64) { 807 | self.metric_sint64 = ::std::option::Option::Some(v); 808 | } 809 | 810 | // optional double metric_d = 14; 811 | 812 | 813 | pub fn get_metric_d(&self) -> f64 { 814 | self.metric_d.unwrap_or(0.) 815 | } 816 | pub fn clear_metric_d(&mut self) { 817 | self.metric_d = ::std::option::Option::None; 818 | } 819 | 820 | pub fn has_metric_d(&self) -> bool { 821 | self.metric_d.is_some() 822 | } 823 | 824 | // Param is passed by value, moved 825 | pub fn set_metric_d(&mut self, v: f64) { 826 | self.metric_d = ::std::option::Option::Some(v); 827 | } 828 | 829 | // optional float metric_f = 15; 830 | 831 | 832 | pub fn get_metric_f(&self) -> f32 { 833 | self.metric_f.unwrap_or(0.) 834 | } 835 | pub fn clear_metric_f(&mut self) { 836 | self.metric_f = ::std::option::Option::None; 837 | } 838 | 839 | pub fn has_metric_f(&self) -> bool { 840 | self.metric_f.is_some() 841 | } 842 | 843 | // Param is passed by value, moved 844 | pub fn set_metric_f(&mut self, v: f32) { 845 | self.metric_f = ::std::option::Option::Some(v); 846 | } 847 | } 848 | 849 | impl ::protobuf::Message for Event { 850 | fn is_initialized(&self) -> bool { 851 | for v in &self.attributes { 852 | if !v.is_initialized() { 853 | return false; 854 | } 855 | }; 856 | true 857 | } 858 | 859 | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { 860 | while !is.eof()? { 861 | let (field_number, wire_type) = is.read_tag_unpack()?; 862 | match field_number { 863 | 1 => { 864 | if wire_type != ::protobuf::wire_format::WireTypeVarint { 865 | return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); 866 | } 867 | let tmp = is.read_int64()?; 868 | self.time = ::std::option::Option::Some(tmp); 869 | }, 870 | 2 => { 871 | ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.state)?; 872 | }, 873 | 3 => { 874 | ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.service)?; 875 | }, 876 | 4 => { 877 | ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.host)?; 878 | }, 879 | 5 => { 880 | ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.description)?; 881 | }, 882 | 7 => { 883 | ::protobuf::rt::read_repeated_string_into(wire_type, is, &mut self.tags)?; 884 | }, 885 | 8 => { 886 | if wire_type != ::protobuf::wire_format::WireTypeFixed32 { 887 | return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); 888 | } 889 | let tmp = is.read_float()?; 890 | self.ttl = ::std::option::Option::Some(tmp); 891 | }, 892 | 9 => { 893 | ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.attributes)?; 894 | }, 895 | 10 => { 896 | if wire_type != ::protobuf::wire_format::WireTypeVarint { 897 | return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); 898 | } 899 | let tmp = is.read_int64()?; 900 | self.time_micros = ::std::option::Option::Some(tmp); 901 | }, 902 | 13 => { 903 | if wire_type != ::protobuf::wire_format::WireTypeVarint { 904 | return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); 905 | } 906 | let tmp = is.read_sint64()?; 907 | self.metric_sint64 = ::std::option::Option::Some(tmp); 908 | }, 909 | 14 => { 910 | if wire_type != ::protobuf::wire_format::WireTypeFixed64 { 911 | return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); 912 | } 913 | let tmp = is.read_double()?; 914 | self.metric_d = ::std::option::Option::Some(tmp); 915 | }, 916 | 15 => { 917 | if wire_type != ::protobuf::wire_format::WireTypeFixed32 { 918 | return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); 919 | } 920 | let tmp = is.read_float()?; 921 | self.metric_f = ::std::option::Option::Some(tmp); 922 | }, 923 | _ => { 924 | ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; 925 | }, 926 | }; 927 | } 928 | ::std::result::Result::Ok(()) 929 | } 930 | 931 | // Compute sizes of nested messages 932 | #[allow(unused_variables)] 933 | fn compute_size(&self) -> u32 { 934 | let mut my_size = 0; 935 | if let Some(v) = self.time { 936 | my_size += ::protobuf::rt::value_size(1, v, ::protobuf::wire_format::WireTypeVarint); 937 | } 938 | if let Some(ref v) = self.state.as_ref() { 939 | my_size += ::protobuf::rt::string_size(2, &v); 940 | } 941 | if let Some(ref v) = self.service.as_ref() { 942 | my_size += ::protobuf::rt::string_size(3, &v); 943 | } 944 | if let Some(ref v) = self.host.as_ref() { 945 | my_size += ::protobuf::rt::string_size(4, &v); 946 | } 947 | if let Some(ref v) = self.description.as_ref() { 948 | my_size += ::protobuf::rt::string_size(5, &v); 949 | } 950 | for value in &self.tags { 951 | my_size += ::protobuf::rt::string_size(7, &value); 952 | }; 953 | if let Some(v) = self.ttl { 954 | my_size += 5; 955 | } 956 | for value in &self.attributes { 957 | let len = value.compute_size(); 958 | my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; 959 | }; 960 | if let Some(v) = self.time_micros { 961 | my_size += ::protobuf::rt::value_size(10, v, ::protobuf::wire_format::WireTypeVarint); 962 | } 963 | if let Some(v) = self.metric_sint64 { 964 | my_size += ::protobuf::rt::value_varint_zigzag_size(13, v); 965 | } 966 | if let Some(v) = self.metric_d { 967 | my_size += 9; 968 | } 969 | if let Some(v) = self.metric_f { 970 | my_size += 5; 971 | } 972 | my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); 973 | self.cached_size.set(my_size); 974 | my_size 975 | } 976 | 977 | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { 978 | if let Some(v) = self.time { 979 | os.write_int64(1, v)?; 980 | } 981 | if let Some(ref v) = self.state.as_ref() { 982 | os.write_string(2, &v)?; 983 | } 984 | if let Some(ref v) = self.service.as_ref() { 985 | os.write_string(3, &v)?; 986 | } 987 | if let Some(ref v) = self.host.as_ref() { 988 | os.write_string(4, &v)?; 989 | } 990 | if let Some(ref v) = self.description.as_ref() { 991 | os.write_string(5, &v)?; 992 | } 993 | for v in &self.tags { 994 | os.write_string(7, &v)?; 995 | }; 996 | if let Some(v) = self.ttl { 997 | os.write_float(8, v)?; 998 | } 999 | for v in &self.attributes { 1000 | os.write_tag(9, ::protobuf::wire_format::WireTypeLengthDelimited)?; 1001 | os.write_raw_varint32(v.get_cached_size())?; 1002 | v.write_to_with_cached_sizes(os)?; 1003 | }; 1004 | if let Some(v) = self.time_micros { 1005 | os.write_int64(10, v)?; 1006 | } 1007 | if let Some(v) = self.metric_sint64 { 1008 | os.write_sint64(13, v)?; 1009 | } 1010 | if let Some(v) = self.metric_d { 1011 | os.write_double(14, v)?; 1012 | } 1013 | if let Some(v) = self.metric_f { 1014 | os.write_float(15, v)?; 1015 | } 1016 | os.write_unknown_fields(self.get_unknown_fields())?; 1017 | ::std::result::Result::Ok(()) 1018 | } 1019 | 1020 | fn get_cached_size(&self) -> u32 { 1021 | self.cached_size.get() 1022 | } 1023 | 1024 | fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { 1025 | &self.unknown_fields 1026 | } 1027 | 1028 | fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { 1029 | &mut self.unknown_fields 1030 | } 1031 | 1032 | fn as_any(&self) -> &dyn (::std::any::Any) { 1033 | self as &dyn (::std::any::Any) 1034 | } 1035 | fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { 1036 | self as &mut dyn (::std::any::Any) 1037 | } 1038 | fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { 1039 | self 1040 | } 1041 | 1042 | fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { 1043 | Self::descriptor_static() 1044 | } 1045 | 1046 | fn new() -> Event { 1047 | Event::new() 1048 | } 1049 | 1050 | fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { 1051 | static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; 1052 | descriptor.get(|| { 1053 | let mut fields = ::std::vec::Vec::new(); 1054 | fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeInt64>( 1055 | "time", 1056 | |m: &Event| { &m.time }, 1057 | |m: &mut Event| { &mut m.time }, 1058 | )); 1059 | fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( 1060 | "state", 1061 | |m: &Event| { &m.state }, 1062 | |m: &mut Event| { &mut m.state }, 1063 | )); 1064 | fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( 1065 | "service", 1066 | |m: &Event| { &m.service }, 1067 | |m: &mut Event| { &mut m.service }, 1068 | )); 1069 | fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( 1070 | "host", 1071 | |m: &Event| { &m.host }, 1072 | |m: &mut Event| { &mut m.host }, 1073 | )); 1074 | fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( 1075 | "description", 1076 | |m: &Event| { &m.description }, 1077 | |m: &mut Event| { &mut m.description }, 1078 | )); 1079 | fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( 1080 | "tags", 1081 | |m: &Event| { &m.tags }, 1082 | |m: &mut Event| { &mut m.tags }, 1083 | )); 1084 | fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeFloat>( 1085 | "ttl", 1086 | |m: &Event| { &m.ttl }, 1087 | |m: &mut Event| { &mut m.ttl }, 1088 | )); 1089 | fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( 1090 | "attributes", 1091 | |m: &Event| { &m.attributes }, 1092 | |m: &mut Event| { &mut m.attributes }, 1093 | )); 1094 | fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeInt64>( 1095 | "time_micros", 1096 | |m: &Event| { &m.time_micros }, 1097 | |m: &mut Event| { &mut m.time_micros }, 1098 | )); 1099 | fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeSint64>( 1100 | "metric_sint64", 1101 | |m: &Event| { &m.metric_sint64 }, 1102 | |m: &mut Event| { &mut m.metric_sint64 }, 1103 | )); 1104 | fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeDouble>( 1105 | "metric_d", 1106 | |m: &Event| { &m.metric_d }, 1107 | |m: &mut Event| { &mut m.metric_d }, 1108 | )); 1109 | fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeFloat>( 1110 | "metric_f", 1111 | |m: &Event| { &m.metric_f }, 1112 | |m: &mut Event| { &mut m.metric_f }, 1113 | )); 1114 | ::protobuf::reflect::MessageDescriptor::new_pb_name::( 1115 | "Event", 1116 | fields, 1117 | file_descriptor_proto() 1118 | ) 1119 | }) 1120 | } 1121 | 1122 | fn default_instance() -> &'static Event { 1123 | static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; 1124 | instance.get(Event::new) 1125 | } 1126 | } 1127 | 1128 | impl ::protobuf::Clear for Event { 1129 | fn clear(&mut self) { 1130 | self.time = ::std::option::Option::None; 1131 | self.state.clear(); 1132 | self.service.clear(); 1133 | self.host.clear(); 1134 | self.description.clear(); 1135 | self.tags.clear(); 1136 | self.ttl = ::std::option::Option::None; 1137 | self.attributes.clear(); 1138 | self.time_micros = ::std::option::Option::None; 1139 | self.metric_sint64 = ::std::option::Option::None; 1140 | self.metric_d = ::std::option::Option::None; 1141 | self.metric_f = ::std::option::Option::None; 1142 | self.unknown_fields.clear(); 1143 | } 1144 | } 1145 | 1146 | impl ::std::fmt::Debug for Event { 1147 | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { 1148 | ::protobuf::text_format::fmt(self, f) 1149 | } 1150 | } 1151 | 1152 | impl ::protobuf::reflect::ProtobufValue for Event { 1153 | fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { 1154 | ::protobuf::reflect::ReflectValueRef::Message(self) 1155 | } 1156 | } 1157 | 1158 | #[derive(PartialEq,Clone,Default)] 1159 | pub struct Query { 1160 | // message fields 1161 | string: ::protobuf::SingularField<::std::string::String>, 1162 | // special fields 1163 | pub unknown_fields: ::protobuf::UnknownFields, 1164 | pub cached_size: ::protobuf::CachedSize, 1165 | } 1166 | 1167 | impl<'a> ::std::default::Default for &'a Query { 1168 | fn default() -> &'a Query { 1169 | ::default_instance() 1170 | } 1171 | } 1172 | 1173 | impl Query { 1174 | pub fn new() -> Query { 1175 | ::std::default::Default::default() 1176 | } 1177 | 1178 | // optional string string = 1; 1179 | 1180 | 1181 | pub fn get_string(&self) -> &str { 1182 | match self.string.as_ref() { 1183 | Some(v) => &v, 1184 | None => "", 1185 | } 1186 | } 1187 | pub fn clear_string(&mut self) { 1188 | self.string.clear(); 1189 | } 1190 | 1191 | pub fn has_string(&self) -> bool { 1192 | self.string.is_some() 1193 | } 1194 | 1195 | // Param is passed by value, moved 1196 | pub fn set_string(&mut self, v: ::std::string::String) { 1197 | self.string = ::protobuf::SingularField::some(v); 1198 | } 1199 | 1200 | // Mutable pointer to the field. 1201 | // If field is not initialized, it is initialized with default value first. 1202 | pub fn mut_string(&mut self) -> &mut ::std::string::String { 1203 | if self.string.is_none() { 1204 | self.string.set_default(); 1205 | } 1206 | self.string.as_mut().unwrap() 1207 | } 1208 | 1209 | // Take field 1210 | pub fn take_string(&mut self) -> ::std::string::String { 1211 | self.string.take().unwrap_or_else(|| ::std::string::String::new()) 1212 | } 1213 | } 1214 | 1215 | impl ::protobuf::Message for Query { 1216 | fn is_initialized(&self) -> bool { 1217 | true 1218 | } 1219 | 1220 | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { 1221 | while !is.eof()? { 1222 | let (field_number, wire_type) = is.read_tag_unpack()?; 1223 | match field_number { 1224 | 1 => { 1225 | ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.string)?; 1226 | }, 1227 | _ => { 1228 | ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; 1229 | }, 1230 | }; 1231 | } 1232 | ::std::result::Result::Ok(()) 1233 | } 1234 | 1235 | // Compute sizes of nested messages 1236 | #[allow(unused_variables)] 1237 | fn compute_size(&self) -> u32 { 1238 | let mut my_size = 0; 1239 | if let Some(ref v) = self.string.as_ref() { 1240 | my_size += ::protobuf::rt::string_size(1, &v); 1241 | } 1242 | my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); 1243 | self.cached_size.set(my_size); 1244 | my_size 1245 | } 1246 | 1247 | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { 1248 | if let Some(ref v) = self.string.as_ref() { 1249 | os.write_string(1, &v)?; 1250 | } 1251 | os.write_unknown_fields(self.get_unknown_fields())?; 1252 | ::std::result::Result::Ok(()) 1253 | } 1254 | 1255 | fn get_cached_size(&self) -> u32 { 1256 | self.cached_size.get() 1257 | } 1258 | 1259 | fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { 1260 | &self.unknown_fields 1261 | } 1262 | 1263 | fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { 1264 | &mut self.unknown_fields 1265 | } 1266 | 1267 | fn as_any(&self) -> &dyn (::std::any::Any) { 1268 | self as &dyn (::std::any::Any) 1269 | } 1270 | fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { 1271 | self as &mut dyn (::std::any::Any) 1272 | } 1273 | fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { 1274 | self 1275 | } 1276 | 1277 | fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { 1278 | Self::descriptor_static() 1279 | } 1280 | 1281 | fn new() -> Query { 1282 | Query::new() 1283 | } 1284 | 1285 | fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { 1286 | static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; 1287 | descriptor.get(|| { 1288 | let mut fields = ::std::vec::Vec::new(); 1289 | fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( 1290 | "string", 1291 | |m: &Query| { &m.string }, 1292 | |m: &mut Query| { &mut m.string }, 1293 | )); 1294 | ::protobuf::reflect::MessageDescriptor::new_pb_name::( 1295 | "Query", 1296 | fields, 1297 | file_descriptor_proto() 1298 | ) 1299 | }) 1300 | } 1301 | 1302 | fn default_instance() -> &'static Query { 1303 | static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; 1304 | instance.get(Query::new) 1305 | } 1306 | } 1307 | 1308 | impl ::protobuf::Clear for Query { 1309 | fn clear(&mut self) { 1310 | self.string.clear(); 1311 | self.unknown_fields.clear(); 1312 | } 1313 | } 1314 | 1315 | impl ::std::fmt::Debug for Query { 1316 | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { 1317 | ::protobuf::text_format::fmt(self, f) 1318 | } 1319 | } 1320 | 1321 | impl ::protobuf::reflect::ProtobufValue for Query { 1322 | fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { 1323 | ::protobuf::reflect::ReflectValueRef::Message(self) 1324 | } 1325 | } 1326 | 1327 | #[derive(PartialEq,Clone,Default)] 1328 | pub struct Msg { 1329 | // message fields 1330 | ok: ::std::option::Option, 1331 | error: ::protobuf::SingularField<::std::string::String>, 1332 | pub states: ::protobuf::RepeatedField, 1333 | pub query: ::protobuf::SingularPtrField, 1334 | pub events: ::protobuf::RepeatedField, 1335 | // special fields 1336 | pub unknown_fields: ::protobuf::UnknownFields, 1337 | pub cached_size: ::protobuf::CachedSize, 1338 | } 1339 | 1340 | impl<'a> ::std::default::Default for &'a Msg { 1341 | fn default() -> &'a Msg { 1342 | ::default_instance() 1343 | } 1344 | } 1345 | 1346 | impl Msg { 1347 | pub fn new() -> Msg { 1348 | ::std::default::Default::default() 1349 | } 1350 | 1351 | // optional bool ok = 2; 1352 | 1353 | 1354 | pub fn get_ok(&self) -> bool { 1355 | self.ok.unwrap_or(false) 1356 | } 1357 | pub fn clear_ok(&mut self) { 1358 | self.ok = ::std::option::Option::None; 1359 | } 1360 | 1361 | pub fn has_ok(&self) -> bool { 1362 | self.ok.is_some() 1363 | } 1364 | 1365 | // Param is passed by value, moved 1366 | pub fn set_ok(&mut self, v: bool) { 1367 | self.ok = ::std::option::Option::Some(v); 1368 | } 1369 | 1370 | // optional string error = 3; 1371 | 1372 | 1373 | pub fn get_error(&self) -> &str { 1374 | match self.error.as_ref() { 1375 | Some(v) => &v, 1376 | None => "", 1377 | } 1378 | } 1379 | pub fn clear_error(&mut self) { 1380 | self.error.clear(); 1381 | } 1382 | 1383 | pub fn has_error(&self) -> bool { 1384 | self.error.is_some() 1385 | } 1386 | 1387 | // Param is passed by value, moved 1388 | pub fn set_error(&mut self, v: ::std::string::String) { 1389 | self.error = ::protobuf::SingularField::some(v); 1390 | } 1391 | 1392 | // Mutable pointer to the field. 1393 | // If field is not initialized, it is initialized with default value first. 1394 | pub fn mut_error(&mut self) -> &mut ::std::string::String { 1395 | if self.error.is_none() { 1396 | self.error.set_default(); 1397 | } 1398 | self.error.as_mut().unwrap() 1399 | } 1400 | 1401 | // Take field 1402 | pub fn take_error(&mut self) -> ::std::string::String { 1403 | self.error.take().unwrap_or_else(|| ::std::string::String::new()) 1404 | } 1405 | 1406 | // repeated .State states = 4; 1407 | 1408 | 1409 | pub fn get_states(&self) -> &[State] { 1410 | &self.states 1411 | } 1412 | pub fn clear_states(&mut self) { 1413 | self.states.clear(); 1414 | } 1415 | 1416 | // Param is passed by value, moved 1417 | pub fn set_states(&mut self, v: ::protobuf::RepeatedField) { 1418 | self.states = v; 1419 | } 1420 | 1421 | // Mutable pointer to the field. 1422 | pub fn mut_states(&mut self) -> &mut ::protobuf::RepeatedField { 1423 | &mut self.states 1424 | } 1425 | 1426 | // Take field 1427 | pub fn take_states(&mut self) -> ::protobuf::RepeatedField { 1428 | ::std::mem::replace(&mut self.states, ::protobuf::RepeatedField::new()) 1429 | } 1430 | 1431 | // optional .Query query = 5; 1432 | 1433 | 1434 | pub fn get_query(&self) -> &Query { 1435 | self.query.as_ref().unwrap_or_else(|| ::default_instance()) 1436 | } 1437 | pub fn clear_query(&mut self) { 1438 | self.query.clear(); 1439 | } 1440 | 1441 | pub fn has_query(&self) -> bool { 1442 | self.query.is_some() 1443 | } 1444 | 1445 | // Param is passed by value, moved 1446 | pub fn set_query(&mut self, v: Query) { 1447 | self.query = ::protobuf::SingularPtrField::some(v); 1448 | } 1449 | 1450 | // Mutable pointer to the field. 1451 | // If field is not initialized, it is initialized with default value first. 1452 | pub fn mut_query(&mut self) -> &mut Query { 1453 | if self.query.is_none() { 1454 | self.query.set_default(); 1455 | } 1456 | self.query.as_mut().unwrap() 1457 | } 1458 | 1459 | // Take field 1460 | pub fn take_query(&mut self) -> Query { 1461 | self.query.take().unwrap_or_else(|| Query::new()) 1462 | } 1463 | 1464 | // repeated .Event events = 6; 1465 | 1466 | 1467 | pub fn get_events(&self) -> &[Event] { 1468 | &self.events 1469 | } 1470 | pub fn clear_events(&mut self) { 1471 | self.events.clear(); 1472 | } 1473 | 1474 | // Param is passed by value, moved 1475 | pub fn set_events(&mut self, v: ::protobuf::RepeatedField) { 1476 | self.events = v; 1477 | } 1478 | 1479 | // Mutable pointer to the field. 1480 | pub fn mut_events(&mut self) -> &mut ::protobuf::RepeatedField { 1481 | &mut self.events 1482 | } 1483 | 1484 | // Take field 1485 | pub fn take_events(&mut self) -> ::protobuf::RepeatedField { 1486 | ::std::mem::replace(&mut self.events, ::protobuf::RepeatedField::new()) 1487 | } 1488 | } 1489 | 1490 | impl ::protobuf::Message for Msg { 1491 | fn is_initialized(&self) -> bool { 1492 | for v in &self.states { 1493 | if !v.is_initialized() { 1494 | return false; 1495 | } 1496 | }; 1497 | for v in &self.query { 1498 | if !v.is_initialized() { 1499 | return false; 1500 | } 1501 | }; 1502 | for v in &self.events { 1503 | if !v.is_initialized() { 1504 | return false; 1505 | } 1506 | }; 1507 | true 1508 | } 1509 | 1510 | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { 1511 | while !is.eof()? { 1512 | let (field_number, wire_type) = is.read_tag_unpack()?; 1513 | match field_number { 1514 | 2 => { 1515 | if wire_type != ::protobuf::wire_format::WireTypeVarint { 1516 | return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); 1517 | } 1518 | let tmp = is.read_bool()?; 1519 | self.ok = ::std::option::Option::Some(tmp); 1520 | }, 1521 | 3 => { 1522 | ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.error)?; 1523 | }, 1524 | 4 => { 1525 | ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.states)?; 1526 | }, 1527 | 5 => { 1528 | ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.query)?; 1529 | }, 1530 | 6 => { 1531 | ::protobuf::rt::read_repeated_message_into(wire_type, is, &mut self.events)?; 1532 | }, 1533 | _ => { 1534 | ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; 1535 | }, 1536 | }; 1537 | } 1538 | ::std::result::Result::Ok(()) 1539 | } 1540 | 1541 | // Compute sizes of nested messages 1542 | #[allow(unused_variables)] 1543 | fn compute_size(&self) -> u32 { 1544 | let mut my_size = 0; 1545 | if let Some(v) = self.ok { 1546 | my_size += 2; 1547 | } 1548 | if let Some(ref v) = self.error.as_ref() { 1549 | my_size += ::protobuf::rt::string_size(3, &v); 1550 | } 1551 | for value in &self.states { 1552 | let len = value.compute_size(); 1553 | my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; 1554 | }; 1555 | if let Some(ref v) = self.query.as_ref() { 1556 | let len = v.compute_size(); 1557 | my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; 1558 | } 1559 | for value in &self.events { 1560 | let len = value.compute_size(); 1561 | my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; 1562 | }; 1563 | my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); 1564 | self.cached_size.set(my_size); 1565 | my_size 1566 | } 1567 | 1568 | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { 1569 | if let Some(v) = self.ok { 1570 | os.write_bool(2, v)?; 1571 | } 1572 | if let Some(ref v) = self.error.as_ref() { 1573 | os.write_string(3, &v)?; 1574 | } 1575 | for v in &self.states { 1576 | os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; 1577 | os.write_raw_varint32(v.get_cached_size())?; 1578 | v.write_to_with_cached_sizes(os)?; 1579 | }; 1580 | if let Some(ref v) = self.query.as_ref() { 1581 | os.write_tag(5, ::protobuf::wire_format::WireTypeLengthDelimited)?; 1582 | os.write_raw_varint32(v.get_cached_size())?; 1583 | v.write_to_with_cached_sizes(os)?; 1584 | } 1585 | for v in &self.events { 1586 | os.write_tag(6, ::protobuf::wire_format::WireTypeLengthDelimited)?; 1587 | os.write_raw_varint32(v.get_cached_size())?; 1588 | v.write_to_with_cached_sizes(os)?; 1589 | }; 1590 | os.write_unknown_fields(self.get_unknown_fields())?; 1591 | ::std::result::Result::Ok(()) 1592 | } 1593 | 1594 | fn get_cached_size(&self) -> u32 { 1595 | self.cached_size.get() 1596 | } 1597 | 1598 | fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { 1599 | &self.unknown_fields 1600 | } 1601 | 1602 | fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { 1603 | &mut self.unknown_fields 1604 | } 1605 | 1606 | fn as_any(&self) -> &dyn (::std::any::Any) { 1607 | self as &dyn (::std::any::Any) 1608 | } 1609 | fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { 1610 | self as &mut dyn (::std::any::Any) 1611 | } 1612 | fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { 1613 | self 1614 | } 1615 | 1616 | fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { 1617 | Self::descriptor_static() 1618 | } 1619 | 1620 | fn new() -> Msg { 1621 | Msg::new() 1622 | } 1623 | 1624 | fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { 1625 | static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; 1626 | descriptor.get(|| { 1627 | let mut fields = ::std::vec::Vec::new(); 1628 | fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeBool>( 1629 | "ok", 1630 | |m: &Msg| { &m.ok }, 1631 | |m: &mut Msg| { &mut m.ok }, 1632 | )); 1633 | fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( 1634 | "error", 1635 | |m: &Msg| { &m.error }, 1636 | |m: &mut Msg| { &mut m.error }, 1637 | )); 1638 | fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( 1639 | "states", 1640 | |m: &Msg| { &m.states }, 1641 | |m: &mut Msg| { &mut m.states }, 1642 | )); 1643 | fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( 1644 | "query", 1645 | |m: &Msg| { &m.query }, 1646 | |m: &mut Msg| { &mut m.query }, 1647 | )); 1648 | fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( 1649 | "events", 1650 | |m: &Msg| { &m.events }, 1651 | |m: &mut Msg| { &mut m.events }, 1652 | )); 1653 | ::protobuf::reflect::MessageDescriptor::new_pb_name::( 1654 | "Msg", 1655 | fields, 1656 | file_descriptor_proto() 1657 | ) 1658 | }) 1659 | } 1660 | 1661 | fn default_instance() -> &'static Msg { 1662 | static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; 1663 | instance.get(Msg::new) 1664 | } 1665 | } 1666 | 1667 | impl ::protobuf::Clear for Msg { 1668 | fn clear(&mut self) { 1669 | self.ok = ::std::option::Option::None; 1670 | self.error.clear(); 1671 | self.states.clear(); 1672 | self.query.clear(); 1673 | self.events.clear(); 1674 | self.unknown_fields.clear(); 1675 | } 1676 | } 1677 | 1678 | impl ::std::fmt::Debug for Msg { 1679 | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { 1680 | ::protobuf::text_format::fmt(self, f) 1681 | } 1682 | } 1683 | 1684 | impl ::protobuf::reflect::ProtobufValue for Msg { 1685 | fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { 1686 | ::protobuf::reflect::ReflectValueRef::Message(self) 1687 | } 1688 | } 1689 | 1690 | #[derive(PartialEq,Clone,Default)] 1691 | pub struct Attribute { 1692 | // message fields 1693 | key: ::protobuf::SingularField<::std::string::String>, 1694 | value: ::protobuf::SingularField<::std::string::String>, 1695 | // special fields 1696 | pub unknown_fields: ::protobuf::UnknownFields, 1697 | pub cached_size: ::protobuf::CachedSize, 1698 | } 1699 | 1700 | impl<'a> ::std::default::Default for &'a Attribute { 1701 | fn default() -> &'a Attribute { 1702 | ::default_instance() 1703 | } 1704 | } 1705 | 1706 | impl Attribute { 1707 | pub fn new() -> Attribute { 1708 | ::std::default::Default::default() 1709 | } 1710 | 1711 | // required string key = 1; 1712 | 1713 | 1714 | pub fn get_key(&self) -> &str { 1715 | match self.key.as_ref() { 1716 | Some(v) => &v, 1717 | None => "", 1718 | } 1719 | } 1720 | pub fn clear_key(&mut self) { 1721 | self.key.clear(); 1722 | } 1723 | 1724 | pub fn has_key(&self) -> bool { 1725 | self.key.is_some() 1726 | } 1727 | 1728 | // Param is passed by value, moved 1729 | pub fn set_key(&mut self, v: ::std::string::String) { 1730 | self.key = ::protobuf::SingularField::some(v); 1731 | } 1732 | 1733 | // Mutable pointer to the field. 1734 | // If field is not initialized, it is initialized with default value first. 1735 | pub fn mut_key(&mut self) -> &mut ::std::string::String { 1736 | if self.key.is_none() { 1737 | self.key.set_default(); 1738 | } 1739 | self.key.as_mut().unwrap() 1740 | } 1741 | 1742 | // Take field 1743 | pub fn take_key(&mut self) -> ::std::string::String { 1744 | self.key.take().unwrap_or_else(|| ::std::string::String::new()) 1745 | } 1746 | 1747 | // optional string value = 2; 1748 | 1749 | 1750 | pub fn get_value(&self) -> &str { 1751 | match self.value.as_ref() { 1752 | Some(v) => &v, 1753 | None => "", 1754 | } 1755 | } 1756 | pub fn clear_value(&mut self) { 1757 | self.value.clear(); 1758 | } 1759 | 1760 | pub fn has_value(&self) -> bool { 1761 | self.value.is_some() 1762 | } 1763 | 1764 | // Param is passed by value, moved 1765 | pub fn set_value(&mut self, v: ::std::string::String) { 1766 | self.value = ::protobuf::SingularField::some(v); 1767 | } 1768 | 1769 | // Mutable pointer to the field. 1770 | // If field is not initialized, it is initialized with default value first. 1771 | pub fn mut_value(&mut self) -> &mut ::std::string::String { 1772 | if self.value.is_none() { 1773 | self.value.set_default(); 1774 | } 1775 | self.value.as_mut().unwrap() 1776 | } 1777 | 1778 | // Take field 1779 | pub fn take_value(&mut self) -> ::std::string::String { 1780 | self.value.take().unwrap_or_else(|| ::std::string::String::new()) 1781 | } 1782 | } 1783 | 1784 | impl ::protobuf::Message for Attribute { 1785 | fn is_initialized(&self) -> bool { 1786 | if self.key.is_none() { 1787 | return false; 1788 | } 1789 | true 1790 | } 1791 | 1792 | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { 1793 | while !is.eof()? { 1794 | let (field_number, wire_type) = is.read_tag_unpack()?; 1795 | match field_number { 1796 | 1 => { 1797 | ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.key)?; 1798 | }, 1799 | 2 => { 1800 | ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.value)?; 1801 | }, 1802 | _ => { 1803 | ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; 1804 | }, 1805 | }; 1806 | } 1807 | ::std::result::Result::Ok(()) 1808 | } 1809 | 1810 | // Compute sizes of nested messages 1811 | #[allow(unused_variables)] 1812 | fn compute_size(&self) -> u32 { 1813 | let mut my_size = 0; 1814 | if let Some(ref v) = self.key.as_ref() { 1815 | my_size += ::protobuf::rt::string_size(1, &v); 1816 | } 1817 | if let Some(ref v) = self.value.as_ref() { 1818 | my_size += ::protobuf::rt::string_size(2, &v); 1819 | } 1820 | my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); 1821 | self.cached_size.set(my_size); 1822 | my_size 1823 | } 1824 | 1825 | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { 1826 | if let Some(ref v) = self.key.as_ref() { 1827 | os.write_string(1, &v)?; 1828 | } 1829 | if let Some(ref v) = self.value.as_ref() { 1830 | os.write_string(2, &v)?; 1831 | } 1832 | os.write_unknown_fields(self.get_unknown_fields())?; 1833 | ::std::result::Result::Ok(()) 1834 | } 1835 | 1836 | fn get_cached_size(&self) -> u32 { 1837 | self.cached_size.get() 1838 | } 1839 | 1840 | fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { 1841 | &self.unknown_fields 1842 | } 1843 | 1844 | fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { 1845 | &mut self.unknown_fields 1846 | } 1847 | 1848 | fn as_any(&self) -> &dyn (::std::any::Any) { 1849 | self as &dyn (::std::any::Any) 1850 | } 1851 | fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { 1852 | self as &mut dyn (::std::any::Any) 1853 | } 1854 | fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { 1855 | self 1856 | } 1857 | 1858 | fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { 1859 | Self::descriptor_static() 1860 | } 1861 | 1862 | fn new() -> Attribute { 1863 | Attribute::new() 1864 | } 1865 | 1866 | fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { 1867 | static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; 1868 | descriptor.get(|| { 1869 | let mut fields = ::std::vec::Vec::new(); 1870 | fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( 1871 | "key", 1872 | |m: &Attribute| { &m.key }, 1873 | |m: &mut Attribute| { &mut m.key }, 1874 | )); 1875 | fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( 1876 | "value", 1877 | |m: &Attribute| { &m.value }, 1878 | |m: &mut Attribute| { &mut m.value }, 1879 | )); 1880 | ::protobuf::reflect::MessageDescriptor::new_pb_name::( 1881 | "Attribute", 1882 | fields, 1883 | file_descriptor_proto() 1884 | ) 1885 | }) 1886 | } 1887 | 1888 | fn default_instance() -> &'static Attribute { 1889 | static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; 1890 | instance.get(Attribute::new) 1891 | } 1892 | } 1893 | 1894 | impl ::protobuf::Clear for Attribute { 1895 | fn clear(&mut self) { 1896 | self.key.clear(); 1897 | self.value.clear(); 1898 | self.unknown_fields.clear(); 1899 | } 1900 | } 1901 | 1902 | impl ::std::fmt::Debug for Attribute { 1903 | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { 1904 | ::protobuf::text_format::fmt(self, f) 1905 | } 1906 | } 1907 | 1908 | impl ::protobuf::reflect::ProtobufValue for Attribute { 1909 | fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { 1910 | ::protobuf::reflect::ReflectValueRef::Message(self) 1911 | } 1912 | } 1913 | 1914 | static file_descriptor_proto_data: &'static [u8] = b"\ 1915 | \n\x13src/proto/mod.proto\"\xbb\x01\n\x05State\x12\x12\n\x04time\x18\x01\ 1916 | \x20\x01(\x03R\x04time\x12\x14\n\x05state\x18\x02\x20\x01(\tR\x05state\ 1917 | \x12\x18\n\x07service\x18\x03\x20\x01(\tR\x07service\x12\x12\n\x04host\ 1918 | \x18\x04\x20\x01(\tR\x04host\x12\x20\n\x0bdescription\x18\x05\x20\x01(\t\ 1919 | R\x0bdescription\x12\x12\n\x04once\x18\x06\x20\x01(\x08R\x04once\x12\x12\ 1920 | \n\x04tags\x18\x07\x20\x03(\tR\x04tags\x12\x10\n\x03ttl\x18\x08\x20\x01(\ 1921 | \x02R\x03ttl\"\xcf\x02\n\x05Event\x12\x12\n\x04time\x18\x01\x20\x01(\x03\ 1922 | R\x04time\x12\x14\n\x05state\x18\x02\x20\x01(\tR\x05state\x12\x18\n\x07s\ 1923 | ervice\x18\x03\x20\x01(\tR\x07service\x12\x12\n\x04host\x18\x04\x20\x01(\ 1924 | \tR\x04host\x12\x20\n\x0bdescription\x18\x05\x20\x01(\tR\x0bdescription\ 1925 | \x12\x12\n\x04tags\x18\x07\x20\x03(\tR\x04tags\x12\x10\n\x03ttl\x18\x08\ 1926 | \x20\x01(\x02R\x03ttl\x12*\n\nattributes\x18\t\x20\x03(\x0b2\n.Attribute\ 1927 | R\nattributes\x12\x1f\n\x0btime_micros\x18\n\x20\x01(\x03R\ntimeMicros\ 1928 | \x12#\n\rmetric_sint64\x18\r\x20\x01(\x12R\x0cmetricSint64\x12\x19\n\x08\ 1929 | metric_d\x18\x0e\x20\x01(\x01R\x07metricD\x12\x19\n\x08metric_f\x18\x0f\ 1930 | \x20\x01(\x02R\x07metricF\"\x1f\n\x05Query\x12\x16\n\x06string\x18\x01\ 1931 | \x20\x01(\tR\x06string\"\x89\x01\n\x03Msg\x12\x0e\n\x02ok\x18\x02\x20\ 1932 | \x01(\x08R\x02ok\x12\x14\n\x05error\x18\x03\x20\x01(\tR\x05error\x12\x1e\ 1933 | \n\x06states\x18\x04\x20\x03(\x0b2\x06.StateR\x06states\x12\x1c\n\x05que\ 1934 | ry\x18\x05\x20\x01(\x0b2\x06.QueryR\x05query\x12\x1e\n\x06events\x18\x06\ 1935 | \x20\x03(\x0b2\x06.EventR\x06events\"3\n\tAttribute\x12\x10\n\x03key\x18\ 1936 | \x01\x20\x02(\tR\x03key\x12\x14\n\x05value\x18\x02\x20\x01(\tR\x05valueB\ 1937 | \x1b\n\x12io.riemann.riemannB\x05ProtoJ\x94\x11\n\x06\x12\x04\0\00\x01\n\ 1938 | \x08\n\x01\x0c\x12\x03\0\0\x12\n\x08\n\x01\x08\x12\x03\x01\0+\n\t\n\x02\ 1939 | \x08\x01\x12\x03\x01\0+\n\x08\n\x01\x08\x12\x03\x02\0&\n\t\n\x02\x08\x08\ 1940 | \x12\x03\x02\0&\n^\n\x02\x04\0\x12\x04\x06\0\x0f\x01\x1aR\x20Deprecated;\ 1941 | \x20state\x20was\x20used\x20by\x20early\x20versions\x20of\x20the\x20prot\ 1942 | ocol,\x20but\x20not\x20any\n\x20more.\n\n\n\n\x03\x04\0\x01\x12\x03\x06\ 1943 | \x08\r\n\x0b\n\x04\x04\0\x02\0\x12\x03\x07\x02\x1a\n\x0c\n\x05\x04\0\x02\ 1944 | \0\x04\x12\x03\x07\x02\n\n\x0c\n\x05\x04\0\x02\0\x05\x12\x03\x07\x0b\x10\ 1945 | \n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x07\x11\x15\n\x0c\n\x05\x04\0\x02\0\ 1946 | \x03\x12\x03\x07\x18\x19\n\x0b\n\x04\x04\0\x02\x01\x12\x03\x08\x02\x1c\n\ 1947 | \x0c\n\x05\x04\0\x02\x01\x04\x12\x03\x08\x02\n\n\x0c\n\x05\x04\0\x02\x01\ 1948 | \x05\x12\x03\x08\x0b\x11\n\x0c\n\x05\x04\0\x02\x01\x01\x12\x03\x08\x12\ 1949 | \x17\n\x0c\n\x05\x04\0\x02\x01\x03\x12\x03\x08\x1a\x1b\n\x0b\n\x04\x04\0\ 1950 | \x02\x02\x12\x03\t\x02\x1e\n\x0c\n\x05\x04\0\x02\x02\x04\x12\x03\t\x02\n\ 1951 | \n\x0c\n\x05\x04\0\x02\x02\x05\x12\x03\t\x0b\x11\n\x0c\n\x05\x04\0\x02\ 1952 | \x02\x01\x12\x03\t\x12\x19\n\x0c\n\x05\x04\0\x02\x02\x03\x12\x03\t\x1c\ 1953 | \x1d\n\x0b\n\x04\x04\0\x02\x03\x12\x03\n\x02\x1b\n\x0c\n\x05\x04\0\x02\ 1954 | \x03\x04\x12\x03\n\x02\n\n\x0c\n\x05\x04\0\x02\x03\x05\x12\x03\n\x0b\x11\ 1955 | \n\x0c\n\x05\x04\0\x02\x03\x01\x12\x03\n\x12\x16\n\x0c\n\x05\x04\0\x02\ 1956 | \x03\x03\x12\x03\n\x19\x1a\n\x0b\n\x04\x04\0\x02\x04\x12\x03\x0b\x02\"\n\ 1957 | \x0c\n\x05\x04\0\x02\x04\x04\x12\x03\x0b\x02\n\n\x0c\n\x05\x04\0\x02\x04\ 1958 | \x05\x12\x03\x0b\x0b\x11\n\x0c\n\x05\x04\0\x02\x04\x01\x12\x03\x0b\x12\ 1959 | \x1d\n\x0c\n\x05\x04\0\x02\x04\x03\x12\x03\x0b\x20!\n\x0b\n\x04\x04\0\ 1960 | \x02\x05\x12\x03\x0c\x02\x19\n\x0c\n\x05\x04\0\x02\x05\x04\x12\x03\x0c\ 1961 | \x02\n\n\x0c\n\x05\x04\0\x02\x05\x05\x12\x03\x0c\x0b\x0f\n\x0c\n\x05\x04\ 1962 | \0\x02\x05\x01\x12\x03\x0c\x10\x14\n\x0c\n\x05\x04\0\x02\x05\x03\x12\x03\ 1963 | \x0c\x17\x18\n\x0b\n\x04\x04\0\x02\x06\x12\x03\r\x02\x1b\n\x0c\n\x05\x04\ 1964 | \0\x02\x06\x04\x12\x03\r\x02\n\n\x0c\n\x05\x04\0\x02\x06\x05\x12\x03\r\ 1965 | \x0b\x11\n\x0c\n\x05\x04\0\x02\x06\x01\x12\x03\r\x12\x16\n\x0c\n\x05\x04\ 1966 | \0\x02\x06\x03\x12\x03\r\x19\x1a\n\x0b\n\x04\x04\0\x02\x07\x12\x03\x0e\ 1967 | \x02\x19\n\x0c\n\x05\x04\0\x02\x07\x04\x12\x03\x0e\x02\n\n\x0c\n\x05\x04\ 1968 | \0\x02\x07\x05\x12\x03\x0e\x0b\x10\n\x0c\n\x05\x04\0\x02\x07\x01\x12\x03\ 1969 | \x0e\x11\x14\n\x0c\n\x05\x04\0\x02\x07\x03\x12\x03\x0e\x17\x18\n\n\n\x02\ 1970 | \x04\x01\x12\x04\x11\0\x1f\x01\n\n\n\x03\x04\x01\x01\x12\x03\x11\x08\r\n\ 1971 | \x0b\n\x04\x04\x01\x02\0\x12\x03\x12\x02\x1a\n\x0c\n\x05\x04\x01\x02\0\ 1972 | \x04\x12\x03\x12\x02\n\n\x0c\n\x05\x04\x01\x02\0\x05\x12\x03\x12\x0b\x10\ 1973 | \n\x0c\n\x05\x04\x01\x02\0\x01\x12\x03\x12\x11\x15\n\x0c\n\x05\x04\x01\ 1974 | \x02\0\x03\x12\x03\x12\x18\x19\n\x0b\n\x04\x04\x01\x02\x01\x12\x03\x13\ 1975 | \x02\x1c\n\x0c\n\x05\x04\x01\x02\x01\x04\x12\x03\x13\x02\n\n\x0c\n\x05\ 1976 | \x04\x01\x02\x01\x05\x12\x03\x13\x0b\x11\n\x0c\n\x05\x04\x01\x02\x01\x01\ 1977 | \x12\x03\x13\x12\x17\n\x0c\n\x05\x04\x01\x02\x01\x03\x12\x03\x13\x1a\x1b\ 1978 | \n\x0b\n\x04\x04\x01\x02\x02\x12\x03\x14\x02\x1e\n\x0c\n\x05\x04\x01\x02\ 1979 | \x02\x04\x12\x03\x14\x02\n\n\x0c\n\x05\x04\x01\x02\x02\x05\x12\x03\x14\ 1980 | \x0b\x11\n\x0c\n\x05\x04\x01\x02\x02\x01\x12\x03\x14\x12\x19\n\x0c\n\x05\ 1981 | \x04\x01\x02\x02\x03\x12\x03\x14\x1c\x1d\n\x0b\n\x04\x04\x01\x02\x03\x12\ 1982 | \x03\x15\x02\x1b\n\x0c\n\x05\x04\x01\x02\x03\x04\x12\x03\x15\x02\n\n\x0c\ 1983 | \n\x05\x04\x01\x02\x03\x05\x12\x03\x15\x0b\x11\n\x0c\n\x05\x04\x01\x02\ 1984 | \x03\x01\x12\x03\x15\x12\x16\n\x0c\n\x05\x04\x01\x02\x03\x03\x12\x03\x15\ 1985 | \x19\x1a\n\x0b\n\x04\x04\x01\x02\x04\x12\x03\x16\x02\"\n\x0c\n\x05\x04\ 1986 | \x01\x02\x04\x04\x12\x03\x16\x02\n\n\x0c\n\x05\x04\x01\x02\x04\x05\x12\ 1987 | \x03\x16\x0b\x11\n\x0c\n\x05\x04\x01\x02\x04\x01\x12\x03\x16\x12\x1d\n\ 1988 | \x0c\n\x05\x04\x01\x02\x04\x03\x12\x03\x16\x20!\n\x0b\n\x04\x04\x01\x02\ 1989 | \x05\x12\x03\x17\x02\x1b\n\x0c\n\x05\x04\x01\x02\x05\x04\x12\x03\x17\x02\ 1990 | \n\n\x0c\n\x05\x04\x01\x02\x05\x05\x12\x03\x17\x0b\x11\n\x0c\n\x05\x04\ 1991 | \x01\x02\x05\x01\x12\x03\x17\x12\x16\n\x0c\n\x05\x04\x01\x02\x05\x03\x12\ 1992 | \x03\x17\x19\x1a\n\x0b\n\x04\x04\x01\x02\x06\x12\x03\x18\x02\x19\n\x0c\n\ 1993 | \x05\x04\x01\x02\x06\x04\x12\x03\x18\x02\n\n\x0c\n\x05\x04\x01\x02\x06\ 1994 | \x05\x12\x03\x18\x0b\x10\n\x0c\n\x05\x04\x01\x02\x06\x01\x12\x03\x18\x11\ 1995 | \x14\n\x0c\n\x05\x04\x01\x02\x06\x03\x12\x03\x18\x17\x18\n\x0b\n\x04\x04\ 1996 | \x01\x02\x07\x12\x03\x19\x02$\n\x0c\n\x05\x04\x01\x02\x07\x04\x12\x03\ 1997 | \x19\x02\n\n\x0c\n\x05\x04\x01\x02\x07\x06\x12\x03\x19\x0b\x14\n\x0c\n\ 1998 | \x05\x04\x01\x02\x07\x01\x12\x03\x19\x15\x1f\n\x0c\n\x05\x04\x01\x02\x07\ 1999 | \x03\x12\x03\x19\"#\n\x0b\n\x04\x04\x01\x02\x08\x12\x03\x1b\x02\"\n\x0c\ 2000 | \n\x05\x04\x01\x02\x08\x04\x12\x03\x1b\x02\n\n\x0c\n\x05\x04\x01\x02\x08\ 2001 | \x05\x12\x03\x1b\x0b\x10\n\x0c\n\x05\x04\x01\x02\x08\x01\x12\x03\x1b\x11\ 2002 | \x1c\n\x0c\n\x05\x04\x01\x02\x08\x03\x12\x03\x1b\x1f!\n\x0b\n\x04\x04\ 2003 | \x01\x02\t\x12\x03\x1c\x02%\n\x0c\n\x05\x04\x01\x02\t\x04\x12\x03\x1c\ 2004 | \x02\n\n\x0c\n\x05\x04\x01\x02\t\x05\x12\x03\x1c\x0b\x11\n\x0c\n\x05\x04\ 2005 | \x01\x02\t\x01\x12\x03\x1c\x12\x1f\n\x0c\n\x05\x04\x01\x02\t\x03\x12\x03\ 2006 | \x1c\"$\n\x0b\n\x04\x04\x01\x02\n\x12\x03\x1d\x02\x20\n\x0c\n\x05\x04\ 2007 | \x01\x02\n\x04\x12\x03\x1d\x02\n\n\x0c\n\x05\x04\x01\x02\n\x05\x12\x03\ 2008 | \x1d\x0b\x11\n\x0c\n\x05\x04\x01\x02\n\x01\x12\x03\x1d\x12\x1a\n\x0c\n\ 2009 | \x05\x04\x01\x02\n\x03\x12\x03\x1d\x1d\x1f\n\x0b\n\x04\x04\x01\x02\x0b\ 2010 | \x12\x03\x1e\x02\x1f\n\x0c\n\x05\x04\x01\x02\x0b\x04\x12\x03\x1e\x02\n\n\ 2011 | \x0c\n\x05\x04\x01\x02\x0b\x05\x12\x03\x1e\x0b\x10\n\x0c\n\x05\x04\x01\ 2012 | \x02\x0b\x01\x12\x03\x1e\x11\x19\n\x0c\n\x05\x04\x01\x02\x0b\x03\x12\x03\ 2013 | \x1e\x1c\x1e\n\n\n\x02\x04\x02\x12\x04!\0#\x01\n\n\n\x03\x04\x02\x01\x12\ 2014 | \x03!\x08\r\n\x0b\n\x04\x04\x02\x02\0\x12\x03\"\x02\x1d\n\x0c\n\x05\x04\ 2015 | \x02\x02\0\x04\x12\x03\"\x02\n\n\x0c\n\x05\x04\x02\x02\0\x05\x12\x03\"\ 2016 | \x0b\x11\n\x0c\n\x05\x04\x02\x02\0\x01\x12\x03\"\x12\x18\n\x0c\n\x05\x04\ 2017 | \x02\x02\0\x03\x12\x03\"\x1b\x1c\n\n\n\x02\x04\x03\x12\x04%\0+\x01\n\n\n\ 2018 | \x03\x04\x03\x01\x12\x03%\x08\x0b\n\x0b\n\x04\x04\x03\x02\0\x12\x03&\x02\ 2019 | \x17\n\x0c\n\x05\x04\x03\x02\0\x04\x12\x03&\x02\n\n\x0c\n\x05\x04\x03\ 2020 | \x02\0\x05\x12\x03&\x0b\x0f\n\x0c\n\x05\x04\x03\x02\0\x01\x12\x03&\x10\ 2021 | \x12\n\x0c\n\x05\x04\x03\x02\0\x03\x12\x03&\x15\x16\n\x0b\n\x04\x04\x03\ 2022 | \x02\x01\x12\x03'\x02\x1c\n\x0c\n\x05\x04\x03\x02\x01\x04\x12\x03'\x02\n\ 2023 | \n\x0c\n\x05\x04\x03\x02\x01\x05\x12\x03'\x0b\x11\n\x0c\n\x05\x04\x03\ 2024 | \x02\x01\x01\x12\x03'\x12\x17\n\x0c\n\x05\x04\x03\x02\x01\x03\x12\x03'\ 2025 | \x1a\x1b\n\x0b\n\x04\x04\x03\x02\x02\x12\x03(\x02\x1c\n\x0c\n\x05\x04\ 2026 | \x03\x02\x02\x04\x12\x03(\x02\n\n\x0c\n\x05\x04\x03\x02\x02\x06\x12\x03(\ 2027 | \x0b\x10\n\x0c\n\x05\x04\x03\x02\x02\x01\x12\x03(\x11\x17\n\x0c\n\x05\ 2028 | \x04\x03\x02\x02\x03\x12\x03(\x1a\x1b\n\x0b\n\x04\x04\x03\x02\x03\x12\ 2029 | \x03)\x02\x1b\n\x0c\n\x05\x04\x03\x02\x03\x04\x12\x03)\x02\n\n\x0c\n\x05\ 2030 | \x04\x03\x02\x03\x06\x12\x03)\x0b\x10\n\x0c\n\x05\x04\x03\x02\x03\x01\ 2031 | \x12\x03)\x11\x16\n\x0c\n\x05\x04\x03\x02\x03\x03\x12\x03)\x19\x1a\n\x0b\ 2032 | \n\x04\x04\x03\x02\x04\x12\x03*\x02\x1c\n\x0c\n\x05\x04\x03\x02\x04\x04\ 2033 | \x12\x03*\x02\n\n\x0c\n\x05\x04\x03\x02\x04\x06\x12\x03*\x0b\x10\n\x0c\n\ 2034 | \x05\x04\x03\x02\x04\x01\x12\x03*\x11\x17\n\x0c\n\x05\x04\x03\x02\x04\ 2035 | \x03\x12\x03*\x1a\x1b\n\n\n\x02\x04\x04\x12\x04-\00\x01\n\n\n\x03\x04\ 2036 | \x04\x01\x12\x03-\x08\x11\n\x0b\n\x04\x04\x04\x02\0\x12\x03.\x02\x1a\n\ 2037 | \x0c\n\x05\x04\x04\x02\0\x04\x12\x03.\x02\n\n\x0c\n\x05\x04\x04\x02\0\ 2038 | \x05\x12\x03.\x0b\x11\n\x0c\n\x05\x04\x04\x02\0\x01\x12\x03.\x12\x15\n\ 2039 | \x0c\n\x05\x04\x04\x02\0\x03\x12\x03.\x18\x19\n\x0b\n\x04\x04\x04\x02\ 2040 | \x01\x12\x03/\x02\x1c\n\x0c\n\x05\x04\x04\x02\x01\x04\x12\x03/\x02\n\n\ 2041 | \x0c\n\x05\x04\x04\x02\x01\x05\x12\x03/\x0b\x11\n\x0c\n\x05\x04\x04\x02\ 2042 | \x01\x01\x12\x03/\x12\x17\n\x0c\n\x05\x04\x04\x02\x01\x03\x12\x03/\x1a\ 2043 | \x1b\ 2044 | "; 2045 | 2046 | static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT; 2047 | 2048 | fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { 2049 | ::protobuf::Message::parse_from_bytes(file_descriptor_proto_data).unwrap() 2050 | } 2051 | 2052 | pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { 2053 | file_descriptor_proto_lazy.get(|| { 2054 | parse_descriptor_proto() 2055 | }) 2056 | } 2057 | --------------------------------------------------------------------------------