mirror of
https://github.com/Devolutions/IronRDP.git
synced 2025-08-04 15:18:17 +00:00
refactor(core): move {Decode/Encode}Error
& document the public API. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
parent
c49f190d29
commit
23bc008d65
155 changed files with 1283 additions and 651 deletions
|
@ -1,5 +1,5 @@
|
|||
use ironrdp_core::WriteBuf;
|
||||
use ironrdp_pdu::{nego, other_err, PduHint};
|
||||
use ironrdp_core::{other_err, WriteBuf};
|
||||
use ironrdp_pdu::{nego, PduHint};
|
||||
use picky::key::PrivateKey;
|
||||
use picky_asn1_x509::{oids, Certificate, ExtensionView, GeneralName};
|
||||
use sspi::credssp::{self, ClientState, CredSspClient};
|
||||
|
@ -43,7 +43,7 @@ struct CredsspTsRequestHint;
|
|||
const CREDSSP_TS_REQUEST_HINT: CredsspTsRequestHint = CredsspTsRequestHint;
|
||||
|
||||
impl PduHint for CredsspTsRequestHint {
|
||||
fn find_size(&self, bytes: &[u8]) -> ironrdp_pdu::DecodeResult<Option<(bool, usize)>> {
|
||||
fn find_size(&self, bytes: &[u8]) -> ironrdp_core::DecodeResult<Option<(bool, usize)>> {
|
||||
match credssp::TsRequest::read_length(bytes) {
|
||||
Ok(length) => Ok(Some((true, length))),
|
||||
Err(e) if e.kind() == std::io::ErrorKind::UnexpectedEof => Ok(None),
|
||||
|
@ -58,7 +58,7 @@ struct CredsspEarlyUserAuthResultHint;
|
|||
const CREDSSP_EARLY_USER_AUTH_RESULT_HINT: CredsspEarlyUserAuthResultHint = CredsspEarlyUserAuthResultHint;
|
||||
|
||||
impl PduHint for CredsspEarlyUserAuthResultHint {
|
||||
fn find_size(&self, _: &[u8]) -> ironrdp_pdu::DecodeResult<Option<(bool, usize)>> {
|
||||
fn find_size(&self, _: &[u8]) -> ironrdp_core::DecodeResult<Option<(bool, usize)>> {
|
||||
Ok(Some((true, credssp::EARLY_USER_AUTH_RESULT_PDU_SIZE)))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -248,8 +248,8 @@ pub type ConnectorResult<T> = Result<T, ConnectorError>;
|
|||
#[non_exhaustive]
|
||||
#[derive(Debug)]
|
||||
pub enum ConnectorErrorKind {
|
||||
Encode(ironrdp_pdu::EncodeError),
|
||||
Decode(ironrdp_pdu::DecodeError),
|
||||
Encode(ironrdp_core::EncodeError),
|
||||
Decode(ironrdp_core::DecodeError),
|
||||
Credssp(sspi::Error),
|
||||
Reason(String),
|
||||
AccessDenied,
|
||||
|
@ -288,8 +288,8 @@ impl std::error::Error for ConnectorErrorKind {
|
|||
pub type ConnectorError = ironrdp_error::Error<ConnectorErrorKind>;
|
||||
|
||||
pub trait ConnectorErrorExt {
|
||||
fn encode(error: ironrdp_pdu::EncodeError) -> Self;
|
||||
fn decode(error: ironrdp_pdu::DecodeError) -> Self;
|
||||
fn encode(error: ironrdp_core::EncodeError) -> Self;
|
||||
fn decode(error: ironrdp_core::DecodeError) -> Self;
|
||||
fn general(context: &'static str) -> Self;
|
||||
fn reason(context: &'static str, reason: impl Into<String>) -> Self;
|
||||
fn custom<E>(context: &'static str, e: E) -> Self
|
||||
|
@ -298,11 +298,11 @@ pub trait ConnectorErrorExt {
|
|||
}
|
||||
|
||||
impl ConnectorErrorExt for ConnectorError {
|
||||
fn encode(error: ironrdp_pdu::EncodeError) -> Self {
|
||||
fn encode(error: ironrdp_core::EncodeError) -> Self {
|
||||
Self::new("encode error", ConnectorErrorKind::Encode(error))
|
||||
}
|
||||
|
||||
fn decode(error: ironrdp_pdu::DecodeError) -> Self {
|
||||
fn decode(error: ironrdp_core::DecodeError) -> Self {
|
||||
Self::new("decode error", ConnectorErrorKind::Decode(error))
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue