Skip to main content

StepImageCollection

Struct StepImageCollection 

Source
pub struct StepImageCollection {
    pub images: HashMap<usize, HashMap<usize, String>>,
}
Expand description

Represents the complete collection of step images for a recipe.

Images are discovered based on the Cooklang naming convention:

  • RecipeName.N.ext: Stored at [0][N-1] (section 0 = linear/no section)
  • RecipeName.S.N.ext: Stored at [S-1][N-1] (section S, step N)

File numbering is one-indexed (Recipe.1.jpg = first step) Internal HashMap keys are zero-indexed Section 0 is reserved for linear recipes without sections.

Supported extensions: jpg, jpeg, png, webp

Fields§

§images: HashMap<usize, HashMap<usize, String>>

Two-dimensional map: section_index -> step_index -> image_path

  • Section 0: steps for linear recipes (Recipe.N.ext stored at [0][N-1])
  • Section 1+: steps within sections (Recipe.S.N.ext stored at [S-1][N-1])

HashMap keys are zero-indexed

Implementations§

Source§

impl StepImageCollection

Source

pub fn is_empty(&self) -> bool

Returns true if there are any images in the collection

Source

pub fn count(&self) -> usize

Returns total count of all images across all sections

Source

pub fn get(&self, section: usize, step: usize) -> Option<&String>

Gets an image for a specific section and step.

§Arguments
  • section - Section number (0 for linear recipes, 1+ for sectioned recipes, one-indexed for sections)
  • step - One-indexed step number (1 = first step)
§Returns

Image path if found, None otherwise

§Examples
// Get step 3 in linear recipe (Recipe.3.jpg stored at [0][2])
let img = images.get(0, 3);

// Get section 2, step 4 (Recipe.2.4.jpg stored at [1][3])
let img = images.get(2, 4);

Trait Implementations§

Source§

impl Clone for StepImageCollection

Source§

fn clone(&self) -> StepImageCollection

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StepImageCollection

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for StepImageCollection

Source§

fn default() -> StepImageCollection

Returns the “default value” for a type. Read more
Source§

impl From<&StepImageCollection> for FfiStepImages

Source§

fn from(c: &StepImageCollection) -> Self

Converts to this type from the input type.
Source§

impl Serialize for StepImageCollection

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, UT> HandleAlloc<UT> for T
where T: Send + Sync,

Source§

fn new_handle(value: Arc<T>) -> Handle

Create a new handle for an Arc value Read more
Source§

unsafe fn clone_handle(handle: Handle) -> Handle

Clone a handle Read more
Source§

unsafe fn consume_handle(handle: Handle) -> Arc<T>

Consume a handle, getting back the initial Arc<> Read more
Source§

unsafe fn get_arc(handle: Handle) -> Arc<Self>

Get a clone of the Arc<> using a “borrowed” handle. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.