Files

112 lines
2.4 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 Written: IDisposable
{
private unsafe Raw.Written* _inner;
public OptionalUsize Size
{
get
{
return GetSize();
}
}
public WrittenType WrittenType
{
get
{
return GetWrittenType();
}
}
/// <summary>
/// Creates a managed <c>Written</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 Written(Raw.Written* handle)
{
_inner = handle;
}
/// <returns>
/// A <c>WrittenType</c> allocated on C# side.
/// </returns>
public WrittenType GetWrittenType()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("Written");
}
Raw.WrittenType retVal = Raw.Written.GetWrittenType(_inner);
return (WrittenType)retVal;
}
}
/// <returns>
/// A <c>OptionalUsize</c> allocated on Rust side.
/// </returns>
public OptionalUsize GetSize()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("Written");
}
Raw.OptionalUsize* retVal = Raw.Written.GetSize(_inner);
return new OptionalUsize(retVal);
}
}
/// <summary>
/// Returns the underlying raw handle.
/// </summary>
public unsafe Raw.Written* AsFFI()
{
return _inner;
}
/// <summary>
/// Destroys the underlying object immediately.
/// </summary>
public void Dispose()
{
unsafe
{
if (_inner == null)
{
return;
}
Raw.Written.Destroy(_inner);
_inner = null;
GC.SuppressFinalize(this);
}
}
~Written()
{
Dispose();
}
}