Struct wireman_core::descriptor::ProtoDescriptor
source · pub struct ProtoDescriptor { /* private fields */ }
Implementations§
source§impl ProtoDescriptor
impl ProtoDescriptor
sourcepub fn new(
includes: impl IntoIterator<Item = impl AsRef<Path>>,
files: impl IntoIterator<Item = impl AsRef<Path>>,
) -> Result<Self>
pub fn new( includes: impl IntoIterator<Item = impl AsRef<Path>>, files: impl IntoIterator<Item = impl AsRef<Path>>, ) -> Result<Self>
Instantiate DescriptorPool
from proto files and include paths
§Errors
- Failed to compile proto
ProtoxCompileError
- Failed to generate descriptor
DescriptorError
Examples found in repository?
examples/metadata.rs (lines 11-14)
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
fn main() -> Result<()> {
let desc = ProtoDescriptor::new(
vec!["/Users/philippreiter/Rust/wireman/example"],
vec!["grpc_simple/debugger.proto"],
)?;
let service = &desc.get_services()[0];
let method = &desc.get_methods(service)[1];
println!("Service: {:}", service.full_name());
println!("Method: {:}", method.full_name());
let mut req = desc.get_request(&method);
req.set_address("http://localhost:50051");
let resp = do_request(&req)?;
println!("\nResponse:\n{:}", resp.message.to_json()?);
Ok(())
}
sourcepub fn get_service_by_name(&self, name: &str) -> Option<ServiceDescriptor>
pub fn get_service_by_name(&self, name: &str) -> Option<ServiceDescriptor>
Returns a Service by its name
sourcepub fn get_message_by_name(&self, name: &str) -> Option<MessageDescriptor>
pub fn get_message_by_name(&self, name: &str) -> Option<MessageDescriptor>
Returns a Message by its name
sourcepub fn get_method_by_name(
&self,
service_name: &str,
method_name: &str,
) -> Option<MethodDescriptor>
pub fn get_method_by_name( &self, service_name: &str, method_name: &str, ) -> Option<MethodDescriptor>
Returns a Method of a service by its name
sourcepub fn get_services(&self) -> Vec<ServiceDescriptor>
pub fn get_services(&self) -> Vec<ServiceDescriptor>
Returns all Services from the descriptor pool
Examples found in repository?
examples/metadata.rs (line 15)
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
fn main() -> Result<()> {
let desc = ProtoDescriptor::new(
vec!["/Users/philippreiter/Rust/wireman/example"],
vec!["grpc_simple/debugger.proto"],
)?;
let service = &desc.get_services()[0];
let method = &desc.get_methods(service)[1];
println!("Service: {:}", service.full_name());
println!("Method: {:}", method.full_name());
let mut req = desc.get_request(&method);
req.set_address("http://localhost:50051");
let resp = do_request(&req)?;
println!("\nResponse:\n{:}", resp.message.to_json()?);
Ok(())
}
sourcepub fn get_methods(&self, service: &ServiceDescriptor) -> Vec<MethodDescriptor>
pub fn get_methods(&self, service: &ServiceDescriptor) -> Vec<MethodDescriptor>
Examples found in repository?
examples/metadata.rs (line 16)
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
fn main() -> Result<()> {
let desc = ProtoDescriptor::new(
vec!["/Users/philippreiter/Rust/wireman/example"],
vec!["grpc_simple/debugger.proto"],
)?;
let service = &desc.get_services()[0];
let method = &desc.get_methods(service)[1];
println!("Service: {:}", service.full_name());
println!("Method: {:}", method.full_name());
let mut req = desc.get_request(&method);
req.set_address("http://localhost:50051");
let resp = do_request(&req)?;
println!("\nResponse:\n{:}", resp.message.to_json()?);
Ok(())
}
pub fn get_request_descriptor( &self, method: &MethodDescriptor, ) -> MessageDescriptor
pub fn get_response_descriptor( &self, method: &MethodDescriptor, ) -> MessageDescriptor
sourcepub fn get_request(&self, method: &MethodDescriptor) -> RequestMessage
pub fn get_request(&self, method: &MethodDescriptor) -> RequestMessage
Examples found in repository?
examples/metadata.rs (line 20)
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
fn main() -> Result<()> {
let desc = ProtoDescriptor::new(
vec!["/Users/philippreiter/Rust/wireman/example"],
vec!["grpc_simple/debugger.proto"],
)?;
let service = &desc.get_services()[0];
let method = &desc.get_methods(service)[1];
println!("Service: {:}", service.full_name());
println!("Method: {:}", method.full_name());
let mut req = desc.get_request(&method);
req.set_address("http://localhost:50051");
let resp = do_request(&req)?;
println!("\nResponse:\n{:}", resp.message.to_json()?);
Ok(())
}
pub fn get_response(&self, method: &MethodDescriptor) -> ResponseMessage
Trait Implementations§
source§impl Clone for ProtoDescriptor
impl Clone for ProtoDescriptor
source§fn clone(&self) -> ProtoDescriptor
fn clone(&self) -> ProtoDescriptor
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for ProtoDescriptor
impl Debug for ProtoDescriptor
source§impl Default for ProtoDescriptor
impl Default for ProtoDescriptor
source§fn default() -> ProtoDescriptor
fn default() -> ProtoDescriptor
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ProtoDescriptor
impl RefUnwindSafe for ProtoDescriptor
impl Send for ProtoDescriptor
impl Sync for ProtoDescriptor
impl Unpin for ProtoDescriptor
impl UnwindSafe for ProtoDescriptor
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request