// by Diplomat
#pragma warning disable 0105
using System;
using System.Runtime.InteropServices;
using Devolutions.IronRdp.Diplomat;
#pragma warning restore 0105
namespace Devolutions.IronRdp;
#nullable enable
public partial class ConnectionActivationSequence: IDisposable
{
private unsafe Raw.ConnectionActivationSequence* _inner;
public ConnectionActivationState State
{
get
{
return GetState();
}
}
///
/// Creates a managed ConnectionActivationSequence from a raw handle.
///
///
/// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free).
///
/// This constructor assumes the raw struct is allocated on Rust side.
/// If implemented, the custom Drop implementation on Rust side WILL run on destruction.
///
public unsafe ConnectionActivationSequence(Raw.ConnectionActivationSequence* handle)
{
_inner = handle;
}
///
/// A ConnectionActivationState allocated on Rust side.
///
public ConnectionActivationState GetState()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("ConnectionActivationSequence");
}
Raw.ConnectionActivationState* retVal = Raw.ConnectionActivationSequence.GetState(_inner);
return new ConnectionActivationState(retVal);
}
}
///
///
/// A PduHint allocated on Rust side.
///
public PduHint NextPduHint()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("ConnectionActivationSequence");
}
Raw.ConnectorActivationFfiResultOptBoxPduHintBoxIronRdpError result = Raw.ConnectionActivationSequence.NextPduHint(_inner);
if (!result.isOk)
{
throw new IronRdpException(new IronRdpError(result.Err));
}
Raw.PduHint* retVal = result.Ok;
if (retVal == null)
{
return null;
}
return new PduHint(retVal);
}
}
///
///
/// A Written allocated on Rust side.
///
public Written Step(byte[] pduHint, WriteBuf buf)
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("ConnectionActivationSequence");
}
nuint pduHintLength = (nuint)pduHint.Length;
Raw.WriteBuf* bufRaw;
bufRaw = buf.AsFFI();
if (bufRaw == null)
{
throw new ObjectDisposedException("WriteBuf");
}
fixed (byte* pduHintPtr = pduHint)
{
Raw.ConnectorActivationFfiResultBoxWrittenBoxIronRdpError result = Raw.ConnectionActivationSequence.Step(_inner, pduHintPtr, pduHintLength, bufRaw);
if (!result.isOk)
{
throw new IronRdpException(new IronRdpError(result.Err));
}
Raw.Written* retVal = result.Ok;
return new Written(retVal);
}
}
}
///
///
/// A Written allocated on Rust side.
///
public Written StepNoInput(WriteBuf buf)
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("ConnectionActivationSequence");
}
Raw.WriteBuf* bufRaw;
bufRaw = buf.AsFFI();
if (bufRaw == null)
{
throw new ObjectDisposedException("WriteBuf");
}
Raw.ConnectorActivationFfiResultBoxWrittenBoxIronRdpError result = Raw.ConnectionActivationSequence.StepNoInput(_inner, bufRaw);
if (!result.isOk)
{
throw new IronRdpException(new IronRdpError(result.Err));
}
Raw.Written* retVal = result.Ok;
return new Written(retVal);
}
}
///
/// Returns the underlying raw handle.
///
public unsafe Raw.ConnectionActivationSequence* AsFFI()
{
return _inner;
}
///
/// Destroys the underlying object immediately.
///
public void Dispose()
{
unsafe
{
if (_inner == null)
{
return;
}
Raw.ConnectionActivationSequence.Destroy(_inner);
_inner = null;
GC.SuppressFinalize(this);
}
}
~ConnectionActivationSequence()
{
Dispose();
}
}