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, IDisposableFlat 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
Constructors
Section titled “Constructors”PgByteaView(PgDatum)
Section titled “PgByteaView(PgDatum)”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.
Methods
Section titled “Methods”CopyTo(Span<byte>)
Section titled “CopyTo(Span<byte>)”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.
DangerousGetSpan()
Section titled “DangerousGetSpan()”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.
Dispose()
Section titled “Dispose()”Releases private storage and invalidates this view and its enumerators.
public void Dispose()GetEnumerator()
Section titled “GetEnumerator()”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.
ToArray()
Section titled “ToArray()”Copies the payload into an independent managed array.
public byte[] ToArray()Returns: byte[]
Bytes that remain valid after the native owner expires.
Properties
Section titled “Properties”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
this[int]
Section titled “this[int]”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.
TypeOid
Section titled “TypeOid”Gets the original PostgreSQL type OID, preserving domain identity.
public uint TypeOid { get; }Value: uint