refactor: rename StaticVirtualChannelProcessor->SvcProcessor

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
Marc-André Lureau 2023-12-13 11:55:25 +04:00 committed by Benoît Cortier
parent f52c1ca5d5
commit 090440a45d
10 changed files with 43 additions and 47 deletions

View file

@ -4,7 +4,7 @@ use ironrdp_connector::{
legacy, reason_err, ConnectorError, ConnectorErrorExt, ConnectorResult, DesktopSize, Sequence, State, Written,
};
use ironrdp_pdu as pdu;
use ironrdp_svc::{StaticChannelSet, StaticVirtualChannelProcessor};
use ironrdp_svc::{StaticChannelSet, SvcProcessor};
use pdu::rdp::capability_sets::CapabilitySet;
use pdu::rdp::headers::ShareControlPdu;
use pdu::write_buf::WriteBuf;
@ -51,7 +51,7 @@ impl Acceptor {
pub fn attach_static_channel<T>(&mut self, channel: T)
where
T: StaticVirtualChannelProcessor + 'static,
T: SvcProcessor + 'static,
{
self.static_channels.insert(channel);
}

View file

@ -11,9 +11,7 @@ pub mod pdu;
use backend::CliprdrBackend;
use ironrdp_pdu::gcc::ChannelName;
use ironrdp_pdu::{decode, PduResult};
use ironrdp_svc::{
impl_as_any, ChannelFlags, CompressionCondition, StaticVirtualChannelProcessor, SvcMessage, SvcProcessorMessages,
};
use ironrdp_svc::{impl_as_any, ChannelFlags, CompressionCondition, SvcMessage, SvcProcessor, SvcProcessorMessages};
use pdu::{
Capabilities, ClientTemporaryDirectory, ClipboardFormat, ClipboardFormatId, ClipboardGeneralCapabilityFlags,
ClipboardPdu, ClipboardProtocolVersion, FileContentsResponse, FormatDataRequest, FormatListResponse,
@ -220,7 +218,7 @@ impl Cliprdr {
}
}
impl StaticVirtualChannelProcessor for Cliprdr {
impl SvcProcessor for Cliprdr {
fn channel_name(&self) -> ChannelName {
Self::CHANNEL_NAME
}

View file

@ -4,7 +4,7 @@ use std::net::SocketAddr;
use ironrdp_pdu::rdp::capability_sets::CapabilitySet;
use ironrdp_pdu::write_buf::WriteBuf;
use ironrdp_pdu::{gcc, mcs, nego, rdp, PduHint};
use ironrdp_svc::{StaticChannelSet, StaticVirtualChannel, StaticVirtualChannelProcessor};
use ironrdp_svc::{StaticChannelSet, StaticVirtualChannel, SvcProcessor};
use crate::channel_connection::{ChannelConnectionSequence, ChannelConnectionState};
use crate::connection_finalization::ConnectionFinalizationSequence;
@ -150,7 +150,7 @@ impl ClientConnector {
#[must_use]
pub fn with_static_channel<T>(mut self, channel: T) -> Self
where
T: StaticVirtualChannelProcessor + 'static,
T: SvcProcessor + 'static,
{
self.static_channels.insert(channel);
self
@ -158,7 +158,7 @@ impl ClientConnector {
pub fn attach_static_channel<T>(&mut self, channel: T)
where
T: StaticVirtualChannelProcessor + 'static,
T: SvcProcessor + 'static,
{
self.static_channels.insert(channel);
}

View file

@ -24,7 +24,7 @@ use ironrdp_pdu::gcc::ChannelName;
use ironrdp_pdu::rdp::vc;
use ironrdp_pdu::write_buf::WriteBuf;
use ironrdp_pdu::{assert_obj_safe, dvc, PduResult};
use ironrdp_svc::{impl_as_any, CompressionCondition, StaticVirtualChannelProcessor, SvcMessage};
use ironrdp_svc::{impl_as_any, CompressionCondition, SvcMessage, SvcProcessor};
use pdu::cursor::WriteCursor;
use pdu::PduEncode;
@ -99,7 +99,7 @@ impl Default for Drdynvc {
}
}
impl StaticVirtualChannelProcessor for Drdynvc {
impl SvcProcessor for Drdynvc {
fn channel_name(&self) -> ChannelName {
Drdynvc::NAME
}

View file

@ -15,7 +15,7 @@ Its important for `PduEncode` to be object-safe in order to enable patterns s
found in `ironrdp-svc`:
```rust
pub trait StaticVirtualChannelProcessor {
pub trait SvcProcessor {
fn process(&mut self, payload: &[u8]) -> PduResult<Vec<Box<dyn PduEncode>>>;
}
```

View file

@ -11,7 +11,7 @@ extern crate tracing;
use ironrdp_pdu::cursor::ReadCursor;
use ironrdp_pdu::gcc::ChannelName;
use ironrdp_pdu::{decode_cursor, other_err, PduResult};
use ironrdp_svc::{impl_as_any, CompressionCondition, StaticVirtualChannelProcessor, SvcMessage};
use ironrdp_svc::{impl_as_any, CompressionCondition, SvcMessage, SvcProcessor};
use pdu::efs::{
Capabilities, ClientDeviceListAnnounce, ClientNameRequest, ClientNameRequestUnicodeFlag, CoreCapability,
CoreCapabilityKind, DeviceControlRequest, DeviceIoRequest, DeviceType, Devices, ServerDeviceAnnounceResponse,
@ -178,7 +178,7 @@ impl Rdpdr {
}
}
impl StaticVirtualChannelProcessor for Rdpdr {
impl SvcProcessor for Rdpdr {
fn channel_name(&self) -> ChannelName {
Self::NAME
}

View file

@ -1,6 +1,6 @@
use ironrdp_pdu::gcc::ChannelName;
use ironrdp_pdu::PduResult;
use ironrdp_svc::{impl_as_any, CompressionCondition, StaticVirtualChannelProcessor, SvcMessage};
use ironrdp_svc::{impl_as_any, CompressionCondition, SvcMessage, SvcProcessor};
/// We currently don't implement any of rdpsnd, however it's required
/// for rdpdr to work: [\[MS-RDPEFS\] Appendix A<1>]
@ -25,7 +25,7 @@ impl Default for Rdpsnd {
impl_as_any!(Rdpsnd);
impl StaticVirtualChannelProcessor for Rdpsnd {
impl SvcProcessor for Rdpsnd {
fn channel_name(&self) -> ChannelName {
Self::NAME
}

View file

@ -7,7 +7,7 @@ use ironrdp_pdu::input::fast_path::{FastPathInput, FastPathInputEvent};
use ironrdp_pdu::rdp::headers::ShareDataPdu;
use ironrdp_pdu::write_buf::WriteBuf;
use ironrdp_pdu::{mcs, Action, PduParsing};
use ironrdp_svc::{StaticVirtualChannelProcessor, SvcProcessorMessages};
use ironrdp_svc::{SvcProcessor, SvcProcessorMessages};
use crate::fast_path::UpdateKind;
use crate::image::DecodedImage;
@ -174,17 +174,17 @@ impl ActiveStage {
self.x224_processor.encode_static(output, pdu)
}
pub fn get_svc_processor<T: StaticVirtualChannelProcessor + 'static>(&mut self) -> Option<&T> {
pub fn get_svc_processor<T: SvcProcessor + 'static>(&mut self) -> Option<&T> {
self.x224_processor.get_svc_processor()
}
pub fn get_svc_processor_mut<T: StaticVirtualChannelProcessor + 'static>(&mut self) -> Option<&mut T> {
pub fn get_svc_processor_mut<T: SvcProcessor + 'static>(&mut self) -> Option<&mut T> {
self.x224_processor.get_svc_processor_mut()
}
/// Completes user's SVC request with data, required to sent it over the network and returns
/// a buffer with encoded data.
pub fn process_svc_processor_messages<C: StaticVirtualChannelProcessor + 'static>(
pub fn process_svc_processor_messages<C: SvcProcessor + 'static>(
&self,
messages: SvcProcessorMessages<C>,
) -> SessionResult<Vec<u8>> {

View file

@ -14,9 +14,7 @@ use ironrdp_pdu::rdp::server_error_info::{ErrorInfo, ProtocolIndependentCode, Se
use ironrdp_pdu::rdp::vc::dvc;
use ironrdp_pdu::write_buf::WriteBuf;
use ironrdp_pdu::{encode_buf, mcs};
use ironrdp_svc::{
StaticChannelSet, StaticVirtualChannel, StaticVirtualChannelProcessor, SvcMessage, SvcProcessorMessages,
};
use ironrdp_svc::{StaticChannelSet, StaticVirtualChannel, SvcMessage, SvcProcessor, SvcProcessorMessages};
use crate::{SessionError, SessionErrorExt as _, SessionResult};
@ -74,13 +72,13 @@ impl Processor {
}
}
pub fn get_svc_processor<T: StaticVirtualChannelProcessor + 'static>(&mut self) -> Option<&T> {
pub fn get_svc_processor<T: SvcProcessor + 'static>(&mut self) -> Option<&T> {
self.static_channels
.get_by_type::<T>()
.and_then(|svc| svc.channel_processor_downcast_ref())
}
pub fn get_svc_processor_mut<T: StaticVirtualChannelProcessor + 'static>(&mut self) -> Option<&mut T> {
pub fn get_svc_processor_mut<T: SvcProcessor + 'static>(&mut self) -> Option<&mut T> {
self.static_channels
.get_by_type_mut::<T>()
.and_then(|svc| svc.channel_processor_downcast_mut())
@ -88,7 +86,7 @@ impl Processor {
/// Completes user's SVC request with data, required to sent it over the network and returns
/// a buffer with encoded data.
pub fn process_svc_processor_messages<C: StaticVirtualChannelProcessor + 'static>(
pub fn process_svc_processor_messages<C: SvcProcessor + 'static>(
&self,
messages: SvcProcessorMessages<C>,
) -> SessionResult<Vec<u8>> {

View file

@ -27,12 +27,12 @@ pub type StaticChannelId = u16;
/// SVC data to be sent to the server. See [`SvcMessage`] for more information.
/// Usually returned by the channel-specific methods.
pub struct SvcProcessorMessages<P: StaticVirtualChannelProcessor> {
pub struct SvcProcessorMessages<P: SvcProcessor> {
messages: Vec<SvcMessage>,
_channel: PhantomData<P>,
}
impl<P: StaticVirtualChannelProcessor> SvcProcessorMessages<P> {
impl<P: SvcProcessor> SvcProcessorMessages<P> {
pub fn new(messages: Vec<SvcMessage>) -> Self {
Self {
messages,
@ -41,13 +41,13 @@ impl<P: StaticVirtualChannelProcessor> SvcProcessorMessages<P> {
}
}
impl<P: StaticVirtualChannelProcessor> From<Vec<SvcMessage>> for SvcProcessorMessages<P> {
impl<P: SvcProcessor> From<Vec<SvcMessage>> for SvcProcessorMessages<P> {
fn from(messages: Vec<SvcMessage>) -> Self {
Self::new(messages)
}
}
impl<P: StaticVirtualChannelProcessor> From<SvcProcessorMessages<P>> for Vec<SvcMessage> {
impl<P: SvcProcessor> From<SvcProcessorMessages<P>> for Vec<SvcMessage> {
fn from(request: SvcProcessorMessages<P>) -> Self {
request.messages
}
@ -96,12 +96,12 @@ pub enum CompressionCondition {
/// A static virtual channel.
#[derive(Debug)]
pub struct StaticVirtualChannel {
channel_processor: Box<dyn StaticVirtualChannelProcessor>,
channel_processor: Box<dyn SvcProcessor>,
chunk_processor: ChunkProcessor,
}
impl StaticVirtualChannel {
pub fn new<T: StaticVirtualChannelProcessor + 'static>(channel_processor: T) -> Self {
pub fn new<T: SvcProcessor + 'static>(channel_processor: T) -> Self {
Self {
channel_processor: Box::new(channel_processor),
chunk_processor: ChunkProcessor::new(),
@ -134,11 +134,11 @@ impl StaticVirtualChannel {
self.channel_processor.is_drdynvc()
}
pub fn channel_processor_downcast_ref<T: StaticVirtualChannelProcessor + 'static>(&self) -> Option<&T> {
pub fn channel_processor_downcast_ref<T: SvcProcessor + 'static>(&self) -> Option<&T> {
self.channel_processor.as_any().downcast_ref()
}
pub fn channel_processor_downcast_mut<T: StaticVirtualChannelProcessor + 'static>(&mut self) -> Option<&mut T> {
pub fn channel_processor_downcast_mut<T: SvcProcessor + 'static>(&mut self) -> Option<&mut T> {
self.channel_processor.as_any_mut().downcast_mut()
}
@ -153,7 +153,7 @@ impl StaticVirtualChannel {
/// communication between client and server components over the main data connection.
/// There are at most 31 (optional) static virtual channels that can be created for a single connection, for a
/// total of 32 static channels when accounting for the non-optional I/O channel.
pub trait StaticVirtualChannelProcessor: AsAny + fmt::Debug + Send {
pub trait SvcProcessor: AsAny + fmt::Debug + Send {
/// Returns the name of the static virtual channel corresponding to this processor.
fn channel_name(&self) -> ChannelName;
@ -175,7 +175,7 @@ pub trait StaticVirtualChannelProcessor: AsAny + fmt::Debug + Send {
}
}
assert_obj_safe!(StaticVirtualChannelProcessor);
assert_obj_safe!(SvcProcessor);
/// ChunkProcessor is used to chunkify/de-chunkify static virtual channel PDUs.
#[derive(Debug)]
@ -345,7 +345,7 @@ macro_rules! impl_as_any {
}
/// A set holding at most one [`StaticVirtualChannel`] for any given type
/// implementing [`StaticVirtualChannelProcessor`].
/// implementing [`SvcProcessor`].
///
/// To ensure uniqueness, each trait object is associated to the [`TypeId`] of its original type.
/// Once joined, channels may have their ID attached using [`Self::attach_channel_id()`], effectively
@ -356,7 +356,7 @@ macro_rules! impl_as_any {
/// the channel ID ([`Self::get_by_channel_id()`]).
///
/// Its possible to downcast the trait object and to retrieve the concrete value
/// since all [`StaticVirtualChannelProcessor`]s are also implementing the [`AsAny`] trait.
/// since all [`SvcProcessor`]s are also implementing the [`AsAny`] trait.
#[derive(Debug)]
pub struct StaticChannelSet {
channels: BTreeMap<TypeId, StaticVirtualChannel>,
@ -377,27 +377,27 @@ impl StaticChannelSet {
/// Inserts a [`StaticVirtualChannel`] into this [`StaticChannelSet`].
///
/// If a static virtual channel of this type already exists, it is returned.
pub fn insert<T: StaticVirtualChannelProcessor + 'static>(&mut self, val: T) -> Option<StaticVirtualChannel> {
pub fn insert<T: SvcProcessor + 'static>(&mut self, val: T) -> Option<StaticVirtualChannel> {
self.channels.insert(TypeId::of::<T>(), StaticVirtualChannel::new(val))
}
/// Gets a reference to a [`StaticVirtualChannel`] by looking up its internal [`StaticVirtualChannelProcessor`]'s [`TypeId`].
/// Gets a reference to a [`StaticVirtualChannel`] by looking up its internal [`SvcProcessor`]'s [`TypeId`].
pub fn get_by_type_id(&self, type_id: TypeId) -> Option<&StaticVirtualChannel> {
self.channels.get(&type_id)
}
/// Gets a mutable reference to a [`StaticVirtualChannel`] by looking up its internal [`StaticVirtualChannelProcessor`]'s [`TypeId`].
/// Gets a mutable reference to a [`StaticVirtualChannel`] by looking up its internal [`SvcProcessor`]'s [`TypeId`].
pub fn get_by_type_id_mut(&mut self, type_id: TypeId) -> Option<&mut StaticVirtualChannel> {
self.channels.get_mut(&type_id)
}
/// Gets a reference to a [`StaticVirtualChannel`] by looking up its internal [`StaticVirtualChannelProcessor`]'s [`TypeId`].
pub fn get_by_type<T: StaticVirtualChannelProcessor + 'static>(&self) -> Option<&StaticVirtualChannel> {
/// Gets a reference to a [`StaticVirtualChannel`] by looking up its internal [`SvcProcessor`]'s [`TypeId`].
pub fn get_by_type<T: SvcProcessor + 'static>(&self) -> Option<&StaticVirtualChannel> {
self.get_by_type_id(TypeId::of::<T>())
}
/// Gets a mutable reference to a [`StaticVirtualChannel`] by looking up its internal [`StaticVirtualChannelProcessor`]'s [`TypeId`].
pub fn get_by_type_mut<T: StaticVirtualChannelProcessor + 'static>(&mut self) -> Option<&mut StaticVirtualChannel> {
/// Gets a mutable reference to a [`StaticVirtualChannel`] by looking up its internal [`SvcProcessor`]'s [`TypeId`].
pub fn get_by_type_mut<T: SvcProcessor + 'static>(&mut self) -> Option<&mut StaticVirtualChannel> {
self.get_by_type_id_mut(TypeId::of::<T>())
}
@ -432,7 +432,7 @@ impl StaticChannelSet {
/// Removes a [`StaticVirtualChannel`] from this [`StaticChannelSet`].
///
/// If a static virtual channel of this type existed, it will be returned.
pub fn remove_by_type<T: StaticVirtualChannelProcessor + 'static>(&mut self) -> Option<StaticVirtualChannel> {
pub fn remove_by_type<T: SvcProcessor + 'static>(&mut self) -> Option<StaticVirtualChannel> {
let type_id = TypeId::of::<T>();
self.remove_by_type_id(type_id)
}
@ -451,7 +451,7 @@ impl StaticChannelSet {
}
/// Gets the attached channel ID for a given static virtual channel.
pub fn get_channel_id_by_type<T: StaticVirtualChannelProcessor + 'static>(&self) -> Option<StaticChannelId> {
pub fn get_channel_id_by_type<T: SvcProcessor + 'static>(&self) -> Option<StaticChannelId> {
self.get_channel_id_by_type_id(TypeId::of::<T>())
}