Files

148 lines
3.6 KiB
C#

// <auto-generated/> 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 GeneratorState: IDisposable
{
private unsafe Raw.GeneratorState* _inner;
public ClientState ClientStateIfCompleted
{
get
{
return GetClientStateIfCompleted();
}
}
public NetworkRequest? NetworkRequestIfSuspended
{
get
{
return GetNetworkRequestIfSuspended();
}
}
/// <summary>
/// Creates a managed <c>GeneratorState</c> from a raw handle.
/// </summary>
/// <remarks>
/// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free).
/// <br/>
/// This constructor assumes the raw struct is allocated on Rust side.
/// If implemented, the custom Drop implementation on Rust side WILL run on destruction.
/// </remarks>
public unsafe GeneratorState(Raw.GeneratorState* handle)
{
_inner = handle;
}
public bool IsSuspended()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("GeneratorState");
}
bool retVal = Raw.GeneratorState.IsSuspended(_inner);
return retVal;
}
}
public bool IsCompleted()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("GeneratorState");
}
bool retVal = Raw.GeneratorState.IsCompleted(_inner);
return retVal;
}
}
/// <returns>
/// A <c>NetworkRequest</c> allocated on Rust side.
/// </returns>
public NetworkRequest? GetNetworkRequestIfSuspended()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("GeneratorState");
}
Raw.NetworkRequest* retVal = Raw.GeneratorState.GetNetworkRequestIfSuspended(_inner);
if (retVal == null)
{
return null;
}
return new NetworkRequest(retVal);
}
}
/// <exception cref="IronRdpException"></exception>
/// <returns>
/// A <c>ClientState</c> allocated on Rust side.
/// </returns>
public ClientState GetClientStateIfCompleted()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("GeneratorState");
}
Raw.CredsspNetworkFfiResultBoxClientStateBoxIronRdpError result = Raw.GeneratorState.GetClientStateIfCompleted(_inner);
if (!result.isOk)
{
throw new IronRdpException(new IronRdpError(result.Err));
}
Raw.ClientState* retVal = result.Ok;
return new ClientState(retVal);
}
}
/// <summary>
/// Returns the underlying raw handle.
/// </summary>
public unsafe Raw.GeneratorState* AsFFI()
{
return _inner;
}
/// <summary>
/// Destroys the underlying object immediately.
/// </summary>
public void Dispose()
{
unsafe
{
if (_inner == null)
{
return;
}
Raw.GeneratorState.Destroy(_inner);
_inner = null;
GC.SuppressFinalize(this);
}
}
~GeneratorState()
{
Dispose();
}
}