Skip to content

PgByteaView

Namespace: Ankus

Assembly: Ankus.Runtime.dll

Borrows a PostgreSQL bytea payload under a checked native lifetime.

public sealed class PgByteaView : IReadOnlyList<byte>, IReadOnlyCollection<byte>, IEnumerable<byte>, IEnumerable, IDisposable

Flat and short values retain their original bytes. PostgreSQL detoasts other storage into a private child context. The source owner must remain alive; direct scalar input views expire at callback exit. Copied length and type metadata remain readable after disposal. Dispose explicitly created views while their backend is active.

Inheritance: object

Implements: IReadOnlyList<byte>, IReadOnlyCollection<byte>, IEnumerable<byte>, IEnumerable, IDisposable

Borrows a PostgreSQL bytea payload under a checked native lifetime.

public PgByteaView(PgDatum value)

Parameters:

value — PgDatum

The present bytea datum, optionally wrapped in a domain.

Flat and short values retain their original bytes. PostgreSQL detoasts other storage into a private child context. The source owner must remain alive; direct scalar input views expire at callback exit. Copied length and type metadata remain readable after disposal. Dispose explicitly created views while their backend is active.

Copies the entire payload after checking its lifetime and the destination capacity.

public void CopyTo(Span<byte> destination)

Parameters:

destination — Span<byte>

Storage large enough for Count bytes.

Checks the lifetime once and exposes the native payload without copying.

public ReadOnlySpan<byte> DangerousGetSpan()

Returns: ReadOnlySpan<byte>

A span whose validity is the caller’s responsibility after this method returns.

Never reset or delete the source owner, dispose this view, or exit its callback while using the span. Keep it on the originating backend thread and do not retain it across backend calls. The span cannot check subsequent native lifetime changes; prefer checked indexing or copies.

Releases private storage and invalidates this view and its enumerators.

public void Dispose()

Creates an independent cursor that checks the native lifetime on every access.

public IEnumerator<byte> GetEnumerator()

Returns: IEnumerator<byte>

A byte enumerator that does not own the underlying view.

Copies the payload into an independent managed array.

public byte[] ToArray()

Returns: byte[]

Bytes that remain valid after the native owner expires.

Gets the payload length, including embedded zero bytes.

public int Count { get; }

Value: int

Gets the checked datum, valid until this view or its source expires.

public PgDatum Datum { get; }

Value: PgDatum

Reads one byte after checking the native lifetime and zero-based index.

public byte this[int index] { get; }

Parameters:

index — int

The zero-based byte index.

Value: byte

The original byte, including zero.

Gets the original PostgreSQL type OID, preserving domain identity.

public uint TypeOid { get; }

Value: uint