mirror of
https://github.com/Devolutions/IronRDP.git
synced 2026-11-23 00:14:10 +00:00
refactor(ffi): mark the IDisposable bridge types (#2164)
The Diplomat version we are moving to makes `IDisposable` opt-in. Without the attribute, a generated wrapper only has a finalizer. Mark the types that `ffi/INTENT.md` says are disposable: - operating-system resources: `ActiveStage`, whose DVC pipe proxies own named-pipe worker threads, and `WinCliprdr`, which owns the clipboard window - large buffers the garbage collector cannot see: `ActiveStageOutputIterator`, `VecU8`, `WriteBuf`, and the clipboard payloads `ClipboardMessage`, `ClipboardSvcMessage`, `FormatDataResponse` and `FfiFileContentsResponse` `DvcPipeProxyMessage` stays unmarked: sending one moves its payload out, so nothing large is left behind. Also mark `CredsspProcessGenerator`. None of the three conditions names it, but it holds `&mut` of its `CredsspSequence`, and the sequence rejects every other call until the generator is released. Releasing it costs nothing. `DecodedImage`, `DecodedPointer` and `ActiveStageOutput` also qualify, but they hand out borrows that outlive the call, which the new generator refuses for disposable types; a later change returns owned data so they can be marked too. The pinned 0.7 macro strips `#[diplomat::attr]`, so this changes no generated code. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
committed by
GitHub
parent
8b4146a34c
commit
18ec4a045e
@@ -4,6 +4,7 @@ pub mod ffi {
|
||||
use crate::error::ffi::IronRdpError;
|
||||
use crate::utils::ffi::VecU8;
|
||||
|
||||
#[diplomat::attr(dotnet, manually_disposable)]
|
||||
#[diplomat::opaque]
|
||||
pub struct ClipboardMessage(pub ironrdp::cliprdr::backend::ClipboardMessage);
|
||||
|
||||
@@ -107,6 +108,7 @@ pub mod ffi {
|
||||
#[diplomat::opaque]
|
||||
pub struct ClipboardFormatIterator(pub Vec<ironrdp::cliprdr::pdu::ClipboardFormat>);
|
||||
|
||||
#[diplomat::attr(dotnet, manually_disposable)]
|
||||
#[diplomat::opaque]
|
||||
pub struct FormatDataResponse(pub Option<ironrdp::cliprdr::pdu::OwnedFormatDataResponse>);
|
||||
|
||||
@@ -152,6 +154,7 @@ pub mod ffi {
|
||||
|
||||
/// Wraps `OwnedFileContentsResponse`, which is a type alias for
|
||||
/// `FileContentsResponse<'static>` (generated by `impl_pdu_borrowing!`).
|
||||
#[diplomat::attr(dotnet, manually_disposable)]
|
||||
#[diplomat::opaque]
|
||||
pub struct FfiFileContentsResponse(pub ironrdp::cliprdr::pdu::OwnedFileContentsResponse);
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ pub mod ffi {
|
||||
#[diplomat::opaque]
|
||||
pub struct Cliprdr(pub Option<ironrdp::cliprdr::Cliprdr<Client>>);
|
||||
|
||||
#[diplomat::attr(dotnet, manually_disposable)]
|
||||
#[diplomat::opaque]
|
||||
pub struct ClipboardSvcMessage(pub Option<ironrdp::cliprdr::CliprdrSvcMessages<Client>>);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ pub mod ffi {
|
||||
use crate::clipboard::message::ffi::ClipboardMessage;
|
||||
use crate::error::ffi::IronRdpError;
|
||||
|
||||
#[diplomat::attr(dotnet, manually_disposable)]
|
||||
#[diplomat::opaque]
|
||||
pub struct WinCliprdr(WinCliprdrInner);
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ pub mod ffi {
|
||||
use crate::error::ffi::IronRdpError;
|
||||
use crate::utils::ffi::VecU8;
|
||||
|
||||
#[diplomat::attr(dotnet, manually_disposable)]
|
||||
#[diplomat::opaque]
|
||||
pub struct CredsspProcessGenerator<'a>(pub ironrdp::connector::credssp::CredsspProcessGenerator<'a>);
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ pub mod ffi {
|
||||
use crate::error::ffi::IronRdpError;
|
||||
use crate::utils::ffi::VecU8;
|
||||
|
||||
#[diplomat::attr(dotnet, manually_disposable)]
|
||||
#[diplomat::opaque]
|
||||
pub struct WriteBuf(pub ironrdp_core::WriteBuf);
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ pub mod ffi {
|
||||
use crate::pdu::ffi::{Action, FastPathInputEventIterator, InclusiveRectangle};
|
||||
use crate::utils::ffi::{BytesSlice, Position, VecU8};
|
||||
|
||||
#[diplomat::attr(dotnet, manually_disposable)]
|
||||
#[diplomat::opaque]
|
||||
pub struct ActiveStage(
|
||||
pub ironrdp::session::ActiveStage,
|
||||
@@ -26,6 +27,7 @@ pub mod ffi {
|
||||
#[diplomat::opaque]
|
||||
pub struct ActiveStageOutput(pub ironrdp::session::ActiveStageOutput);
|
||||
|
||||
#[diplomat::attr(dotnet, manually_disposable)]
|
||||
#[diplomat::opaque]
|
||||
pub struct ActiveStageOutputIterator(pub VecDeque<ironrdp::session::ActiveStageOutput>);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ pub mod ffi {
|
||||
|
||||
use crate::error::ffi::IronRdpError;
|
||||
|
||||
#[diplomat::attr(dotnet, manually_disposable)]
|
||||
#[diplomat::opaque]
|
||||
pub struct VecU8(pub Vec<u8>);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user