Skip to content

PgNativeBox<T>

Namespace: Ankus

Assembly: Ankus.Runtime.dll

Individually owns one unmanaged value in a checked PostgreSQL allocation.

public sealed class PgNativeBox<T> : IDisposable where T : unmanaged

Type parameters:

T

The unmanaged representation copied to and from native storage.

Disposal frees the native allocation without invoking a constructor or destructor on its value. There is no finalizer. The unmanaged constraint does not establish a C ABI layout or SQL type. Native allocator restrictions apply: Bump storage rejects individual disposal and remains live until context cleanup. Use context-owned values when individual release is unavailable.

Inheritance: object

Implements: IDisposable

Gets the requested explicit alignment, or zero for the server default.

public nuint Alignment { get; }

Value: nuint

Gets the allocation’s actual native owner while the allocation remains live.

public PgMemoryContext Context { get; }

Value: PgMemoryContext

Gets the original initialization and native size policies.

public PgAllocationOptions Options { get; }

Value: PgAllocationOptions

Gets or sets a copied unmanaged value after validating the allocation’s native lifetime.

public T Value { get; set; }

Value: T

Borrows a checked typed view without transferring ownership.

public PgNativeReference<T> Borrow()

Returns: PgNativeReference<T>

The view sharing this allocation’s checked lifetime.

Copies all representation bytes into independent context-owned storage.

public PgContextValue<T> CloneInto(PgMemoryContext? context = null)

Parameters:

context — PgMemoryContext

The destination context, or null for the current context.

Returns: PgContextValue<T>

A shallow context-owned copy with default allocation policies.

Copies all representation bytes into independent individually owned storage.

public PgNativeBox<T> CloneOwnedInto(PgMemoryContext? context = null)

Parameters:

context — PgMemoryContext

The destination context, or null for the current context.

Returns: PgNativeBox<T>

A shallow individually owned copy with default allocation policies.

Releases the native storage once; a failed native free retains release rights for retry.

public void Dispose()

Transfers individual release rights to the native context while retaining checked storage and existing views.

public PgContextValue<T> ReleaseToContext()

Returns: PgContextValue<T>

The context-owned value; this owning wrapper becomes consumed.