pub struct Image { /* private fields */ }Expand description
A lazily evaluated image: a handle onto one node of an op graph.
Constructing an Image and chaining ops onto it performs no pixel work
and reads no source bytes beyond the header (SPEC §Guarantees 3). Pixels
move only when a terminal pulls them.
Image is cheap to clone — it shares graph nodes rather than copying them —
and is Send + Sync.
Implementations§
Source§impl Image
impl Image
Sourcepub fn from_producer(producer: Arc<dyn Producer>, format: Format) -> Self
pub fn from_producer(producer: Arc<dyn Producer>, format: Format) -> Self
Build an image rooted at producer.
format is the container the pixels came from, reported by
Image::metadata. Use Format::Raw for pixels the caller supplied
directly.
Sourcepub fn descriptor(&self) -> ImageDescriptor
pub fn descriptor(&self) -> ImageDescriptor
The shape of this image, resolved when the node was built.
Sourcepub fn metadata(&self) -> Result<Metadata>
pub fn metadata(&self) -> Result<Metadata>
Header-only facts about this image.
Free: descriptors flowed forward at graph-build time, so this reads a field and decodes nothing.
§Errors
Infallible for graphs built through this API. It returns Result so
that formats whose headers are parsed lazily can report a malformed
header here without a breaking signature change.
Sourcepub fn apply(&self, op: Arc<dyn Op>) -> Result<Self>
pub fn apply(&self, op: Arc<dyn Op>) -> Result<Self>
Chain a single-input op onto this image.
The op’s output descriptor is computed now, so an op that cannot apply to this input fails here rather than at evaluation time.
§Errors
Propagates Op::output_descriptor, and returns
PixelsError::Graph if op does not take exactly one input.
Sourcepub fn combine(inputs: &[Self], op: Arc<dyn Op>) -> Result<Self>
pub fn combine(inputs: &[Self], op: Arc<dyn Op>) -> Result<Self>
Chain a multi-input op over inputs.
This is how ops like composite join two branches of a graph. The
container format reported by Image::metadata is taken from the first
input.
§Errors
Returns PixelsError::Graph if inputs is empty or its length does
not match Op::arity, and propagates Op::output_descriptor.