-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tonic-reflection: Restructure crate to prep reintroducing v1alpha (#1802
) To simplify API verification, this is a prepatory change to shift around the v1 support to allow for a cleaner v1alpha reintroduction. * Created a multi-file version of the server.rs module * Added mod.rs containing the base error with associated imports * Added v1.rs containing the v1 version of the reflection server
- Loading branch information
Showing
2 changed files
with
39 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
pub use crate::pb::v1::server_reflection_server::{ServerReflection, ServerReflectionServer}; | ||
|
||
use prost::DecodeError; | ||
use std::fmt::{Display, Formatter}; | ||
|
||
mod v1; | ||
|
||
pub use v1::Builder; | ||
|
||
/// Represents an error in the construction of a gRPC Reflection Service. | ||
#[derive(Debug)] | ||
pub enum Error { | ||
/// An error was encountered decoding a `prost_types::FileDescriptorSet` from a buffer. | ||
DecodeError(prost::DecodeError), | ||
/// An invalid `prost_types::FileDescriptorProto` was encountered. | ||
InvalidFileDescriptorSet(String), | ||
} | ||
|
||
impl From<DecodeError> for Error { | ||
fn from(e: DecodeError) -> Self { | ||
Error::DecodeError(e) | ||
} | ||
} | ||
|
||
impl std::error::Error for Error {} | ||
|
||
impl Display for Error { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { | ||
match self { | ||
Error::DecodeError(_) => f.write_str("error decoding FileDescriptorSet from buffer"), | ||
Error::InvalidFileDescriptorSet(s) => { | ||
write!(f, "invalid FileDescriptorSet - {}", s) | ||
} | ||
} | ||
} | ||
} |
33 changes: 3 additions & 30 deletions
33
tonic-reflection/src/server.rs → tonic-reflection/src/server/v1.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters