Module types
Expand description
A collection of useful protobuf types that can be used with rama-grpc.
This crate also introduces the StatusExt trait and implements it in
crate::Status, allowing the implementation of the
gRPC Richer Error Model with rama-grpc in a convenient way.
§Usage
Useful protobuf types are available through the pb module. They can be
imported and worked with directly.
The StatusExt trait adds associated functions to crate::Status that
can be used on the server side to create a status with error details, which
can then be returned to gRPC clients. Moreover, the trait also adds methods
to crate::Status that can be used by a rama-grpc client to extract error
details, and handle them with ease.
§Working with different error message types
Multiple examples are provided at the ErrorDetails doc. Instructions
about how to use the fields of the standard error message types correctly
are provided at error_details.proto.
§Alternative crate::Status associated functions and methods
In the StatusExt doc, an alternative way of interacting with
crate::Status is presented, using vectors of error details structs
wrapped with the ErrorDetail enum. This approach can provide more
control over the vector of standard error messages that will be generated or
that was received, if necessary. To see how to adopt this approach, please
check the StatusExt::try_with_error_details_vec and
StatusExt::get_error_details_vec docs.
Besides that, multiple examples with alternative error details extraction
methods are provided in the StatusExt doc, which can be specially
useful if only one type of standard error message is being handled by the
client. For example, using StatusExt::get_details_bad_request is a
more direct way of extracting a BadRequest error message from
crate::Status.
Modules§
- pb
- Useful protobuf types
Structs§
- BadRequest
- Used to encode/decode the
BadRequeststandard error message described in error_details.proto. Describes violations in a client request. Focuses on the syntactic aspects of the request. - Debug
Info - Used to encode/decode the
DebugInfostandard error message described in error_details.proto. Describes additional debugging info. - Error
Details - Groups the standard error messages structs. Provides associated
functions and methods to setup and edit each error message independently.
Used when extracting error details from
crate::Status, and when creating acrate::Statuswith error details. - Error
Info - Used to encode/decode the
ErrorInfostandard error message described in error_details.proto. Describes the cause of the error with structured details. - Field
Violation - Used at the
field_violationsfield of theBadRequeststruct. Describes a single bad request field. - Help
- Used to encode/decode the
Helpstandard error message described in error_details.proto. Provides links to documentation or for performing an out-of-band action. - Help
Link - Used at the
linksfield of theHelpstruct. Describes a URL link. - Localized
Message - Used to encode/decode the
LocalizedMessagestandard error message described in error_details.proto. Provides a localized error message that is safe to return to the user. - Precondition
Failure - Used to encode/decode the
PreconditionFailurestandard error message described in error_details.proto. Describes what preconditions have failed. - Precondition
Violation - Used at the
violationsfield of thePreconditionFailurestruct. Describes a single precondition failure. - Quota
Failure - Used to encode/decode the
QuotaFailurestandard error message described in error_details.proto. Describes how a quota check failed. - Quota
Violation - Used at the
violationsfield of theQuotaFailurestruct. Describes a single quota violation. - Request
Info - Used to encode/decode the
RequestInfostandard error message described in error_details.proto. Contains metadata about the request that clients can attach when providing feedback. - Resource
Info - Used to encode/decode the
ResourceInfostandard error message described in error_details.proto. Describes the resource that is being accessed. - Retry
Info - Used to encode/decode the
RetryInfostandard error message described in error_details.proto. Describes when the clients can retry a failed request. Note: When obtained from decodingRetryInfomessages, negativeretry_delay’s become 0. - Status
- The
Statustype defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by gRPC. EachStatusmessage contains three pieces of data: error code, error message, and error details.
Enums§
- Error
Detail - Wraps the structs corresponding to the standard error messages, allowing the implementation and handling of vectors containing any of them.
Traits§
- RpcStatus
Ext - Used to implement associated functions and methods on
pb::Status, that allow the extraction of standard error details. This trait is sealed and not meant to be implemented outside oframa::grpc::protobuf::types. - Status
Ext - Used to implement associated functions and methods on
Status, that allow the addition and extraction of standard error details. This trait is sealed and not meant to be implemented outside oframa::grpc::protobuf::types.