Files

112 lines
3.1 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 CredsspProcessGenerator: IDisposable
{
private unsafe Raw.CredsspProcessGenerator* _inner;
/// <summary>
/// Creates a managed <c>CredsspProcessGenerator</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 CredsspProcessGenerator(Raw.CredsspProcessGenerator* handle)
{
_inner = handle;
}
/// <exception cref="IronRdpException"></exception>
/// <returns>
/// A <c>GeneratorState</c> allocated on Rust side.
/// </returns>
public GeneratorState Start()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("CredsspProcessGenerator");
}
Raw.CredsspNetworkFfiResultBoxGeneratorStateBoxIronRdpError result = Raw.CredsspProcessGenerator.Start(_inner);
if (!result.isOk)
{
throw new IronRdpException(new IronRdpError(result.Err));
}
Raw.GeneratorState* retVal = result.Ok;
return new GeneratorState(retVal);
}
}
/// <exception cref="IronRdpException"></exception>
/// <returns>
/// A <c>GeneratorState</c> allocated on Rust side.
/// </returns>
public GeneratorState Resume(byte[] response)
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("CredsspProcessGenerator");
}
nuint responseLength = (nuint)response.Length;
fixed (byte* responsePtr = response)
{
Raw.CredsspNetworkFfiResultBoxGeneratorStateBoxIronRdpError result = Raw.CredsspProcessGenerator.Resume(_inner, responsePtr, responseLength);
if (!result.isOk)
{
throw new IronRdpException(new IronRdpError(result.Err));
}
Raw.GeneratorState* retVal = result.Ok;
return new GeneratorState(retVal);
}
}
}
/// <summary>
/// Returns the underlying raw handle.
/// </summary>
public unsafe Raw.CredsspProcessGenerator* AsFFI()
{
return _inner;
}
/// <summary>
/// Destroys the underlying object immediately.
/// </summary>
public void Dispose()
{
unsafe
{
if (_inner == null)
{
return;
}
Raw.CredsspProcessGenerator.Destroy(_inner);
_inner = null;
GC.SuppressFinalize(this);
}
}
~CredsspProcessGenerator()
{
Dispose();
}
}