Files

120 lines
2.8 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 Scancode: IDisposable
{
private unsafe Raw.Scancode* _inner;
/// <summary>
/// Creates a managed <c>Scancode</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 Scancode(Raw.Scancode* handle)
{
_inner = handle;
}
/// <returns>
/// A <c>Scancode</c> allocated on Rust side.
/// </returns>
public static Scancode FromU8(bool extended, byte code)
{
unsafe
{
Raw.Scancode* retVal = Raw.Scancode.FromU8(extended, code);
return new Scancode(retVal);
}
}
/// <returns>
/// A <c>Scancode</c> allocated on Rust side.
/// </returns>
public static Scancode FromU16(ushort code)
{
unsafe
{
Raw.Scancode* retVal = Raw.Scancode.FromU16(code);
return new Scancode(retVal);
}
}
/// <returns>
/// A <c>Operation</c> allocated on Rust side.
/// </returns>
public Operation AsOperationKeyPressed()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("Scancode");
}
Raw.Operation* retVal = Raw.Scancode.AsOperationKeyPressed(_inner);
return new Operation(retVal);
}
}
/// <returns>
/// A <c>Operation</c> allocated on Rust side.
/// </returns>
public Operation AsOperationKeyReleased()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("Scancode");
}
Raw.Operation* retVal = Raw.Scancode.AsOperationKeyReleased(_inner);
return new Operation(retVal);
}
}
/// <summary>
/// Returns the underlying raw handle.
/// </summary>
public unsafe Raw.Scancode* AsFFI()
{
return _inner;
}
/// <summary>
/// Destroys the underlying object immediately.
/// </summary>
public void Dispose()
{
unsafe
{
if (_inner == null)
{
return;
}
Raw.Scancode.Destroy(_inner);
_inner = null;
GC.SuppressFinalize(this);
}
}
~Scancode()
{
Dispose();
}
}