pub struct ServiceDescriptor { /* private fields */ }
Expand description
A protobuf service definition.
Implementations§
Source§impl ServiceDescriptor
impl ServiceDescriptor
Sourcepub fn new(pool: DescriptorPool, index: usize) -> ServiceDescriptor
pub fn new(pool: DescriptorPool, index: usize) -> ServiceDescriptor
Create a new ServiceDescriptor
referencing the service at index
within the given DescriptorPool
.
§Panics
Panics if index
is out-of-bounds.
Sourcepub fn index(&self) -> usize
pub fn index(&self) -> usize
Returns the index of this ServiceDescriptor
within the parent DescriptorPool
.
Sourcepub fn parent_pool(&self) -> &DescriptorPool
pub fn parent_pool(&self) -> &DescriptorPool
Gets a reference to the DescriptorPool
this service is defined in.
Sourcepub fn parent_file(&self) -> FileDescriptor
pub fn parent_file(&self) -> FileDescriptor
Gets the FileDescriptor
this service is defined in.
Sourcepub fn full_name(&self) -> &str
pub fn full_name(&self) -> &str
Gets the full name of the service, e.g. my.package.Service
.
Examples found in repository?
12async fn main() -> Result<()> {
13 let request = ReflectionRequest::new("http://localhost:50051");
14 let desc = ProtoDescriptor::from_reflection(request).await?;
15 let service = &desc.get_services()[0];
16 let method = &desc.get_methods(service)[1];
17 println!("Service: {:}", service.full_name());
18 println!("Method: {:}", method.full_name());
19 //
20 let mut req = desc.get_request(&method);
21 req.set_address("http://localhost:50051");
22
23 let mut req = desc.get_request(&method);
24 req.set_address("http://localhost:50051");
25
26 Ok(())
27}
More examples
11async fn main() -> Result<()> {
12 let desc = ProtoDescriptor::new(
13 vec!["/Users/philippreiter/Rust/wireman/example"],
14 vec!["grpc_simple/debugger.proto"],
15 )?;
16 let service = &desc.get_services()[0];
17 let method = &desc.get_methods(service)[1];
18 println!("Service: {:}", service.full_name());
19 println!("Method: {:}", method.full_name());
20
21 let mut req = desc.get_request(&method);
22 req.set_address("http://localhost:50051");
23
24 let resp = do_request(&req).await?;
25 println!("\nResponse:\n{:}", resp.message.to_json()?);
26
27 Ok(())
28}
Sourcepub fn package_name(&self) -> &str
pub fn package_name(&self) -> &str
Gets the name of the package this service is defined in, e.g. my.package
.
If no package name is set, an empty string is returned.
Sourcepub fn path(&self) -> &[i32]
pub fn path(&self) -> &[i32]
Gets the path where this service is defined within the FileDescriptorProto
, e.g. [6, 0]
.
See path
for more details on the structure of the path.
Sourcepub fn parent_file_descriptor_proto(&self) -> &FileDescriptorProto
pub fn parent_file_descriptor_proto(&self) -> &FileDescriptorProto
Gets a reference to the FileDescriptorProto
in which this service is defined.
Sourcepub fn service_descriptor_proto(&self) -> &ServiceDescriptorProto
pub fn service_descriptor_proto(&self) -> &ServiceDescriptorProto
Gets a reference to the raw ServiceDescriptorProto
wrapped by this ServiceDescriptor
.
Sourcepub fn options(&self) -> DynamicMessage
pub fn options(&self) -> DynamicMessage
Decodes the options defined for this ServiceDescriptorProto
, including any extension options.
Sourcepub fn methods(&self) -> impl ExactSizeIterator
pub fn methods(&self) -> impl ExactSizeIterator
Gets an iterator yielding a MethodDescriptor
for each method defined in this service.
Trait Implementations§
Source§impl Clone for ServiceDescriptor
impl Clone for ServiceDescriptor
Source§fn clone(&self) -> ServiceDescriptor
fn clone(&self) -> ServiceDescriptor
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ServiceDescriptor
impl Debug for ServiceDescriptor
Source§impl PartialEq for ServiceDescriptor
impl PartialEq for ServiceDescriptor
impl Eq for ServiceDescriptor
impl StructuralPartialEq for ServiceDescriptor
Auto Trait Implementations§
impl Freeze for ServiceDescriptor
impl RefUnwindSafe for ServiceDescriptor
impl Send for ServiceDescriptor
impl Sync for ServiceDescriptor
impl Unpin for ServiceDescriptor
impl UnwindSafe for ServiceDescriptor
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.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>
T
in a tonic::Request