pub struct ServerError { /* private fields */ }Expand description
A code and message exactly as the server supplied them.
The code is preserved as a number so a caller can branch on it; the message
is whatever human-readable text accompanied it, and may be empty. Which
catalog the code comes from is determined by the Error variant carrying
this value — see the module documentation.
§Examples
use lightstreamer_rs::Error;
fn is_bad_credentials(error: &Error) -> bool {
// Appendix A code 1 is "user/password check failed".
matches!(error, Error::Session(cause) if cause.code() == 1)
}Implementations§
Source§impl ServerError
impl ServerError
Sourcepub fn new(code: i64, message: impl Into<String>) -> Self
pub fn new(code: i64, message: impl Into<String>) -> Self
Wraps a code and message as the server sent them.
Sourcepub fn message(&self) -> &str
pub fn message(&self) -> &str
The accompanying text, which the server is allowed to leave empty.
Sourcepub const fn is_adapter_defined(&self) -> bool
pub const fn is_adapter_defined(&self) -> bool
Whether this code came from the server’s Metadata Adapter rather than from the protocol’s own catalog.
A code of 0 or below is supplied by the Adapter and its meaning is
entirely application-specific: no interpretation in
docs/spec/05-error-codes.md applies to it, and only the application
that wrote the Adapter knows what it means
[docs/spec/05-error-codes.md §2].
Trait Implementations§
Source§impl Clone for ServerError
impl Clone for ServerError
Source§fn clone(&self) -> ServerError
fn clone(&self) -> ServerError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more