Function RasterLease.view

Returns a non-owning read-only RasterView borrowing from this lease.

RasterView!T view() nothrow @nogc @trusted;

RasterLease.init is a valid inert lifetime capability. For an uninitialized lease this method returns RasterView!T.init instead of entering the retained-owner borrow path.

A non-empty returned view remains lifetime-bound to this lease.

Example

Example borrowing a read-only view from a retained lease.

import core.stdc.stdlib : malloc;
import raster;

void* memory = malloc(4);
assert(memory !is null);
OwnedByteResource resource;
assert(tryAdoptMallocResource(memory, 4, resource));
const PlaneByteLayout[1] planes = [PlaneByteLayout(0, 2, 1)];
RasterLease!ubyte lease;
assert(tryImportOwnedRaster!ubyte(resource, planes[], Region2D(0, 0, 2, 2), lease).ok);

scope auto view = lease.view();
assert(view.planeCount == 1);
assert(view.width == 2 && view.height == 2);