Trait comfyui_api::comfy::getter::Getter

source ·
pub trait Getter<T, N>
where N: Node + 'static, Self: Default,
{ // Required methods fn get_value<'a>(&self, node: &'a dyn Node) -> Result<&'a T>; fn get_value_mut<'a>(&self, node: &'a mut dyn Node) -> Result<&'a mut T>; // Provided methods fn get<'a>(&self, prompt: &'a Prompt) -> Result<&'a T> { ... } fn get_mut<'a>(&self, prompt: &'a mut Prompt) -> Result<&'a mut T> { ... } fn get_from<'a>( &self, prompt: &'a Prompt, output_node: &str, ) -> Result<&'a T> { ... } fn get_from_mut<'a>( &self, prompt: &'a mut Prompt, output_node: &str, ) -> Result<&'a mut T> { ... } fn get_node<'a>(&self, prompt: &'a Prompt, node: &str) -> Result<&'a T> { ... } fn get_node_mut<'a>( &self, prompt: &'a mut Prompt, node: &str, ) -> Result<&'a mut T> { ... } fn find_node(prompt: &Prompt, output_node: Option<&str>) -> Option<String> { ... } fn guess_node<'a>( prompt: &'a Prompt, output_node: Option<&str>, ) -> Option<&'a dyn Node> { ... } fn guess_node_mut<'a>( prompt: &'a mut Prompt, output_node: Option<&str>, ) -> Option<&'a mut dyn Node> { ... } }
Expand description

A trait for getting values from nodes.

This trait is used to get values from nodes in a Prompt. Implementations of this trait should override get_value and get_value_mut to get the value of interest from a node. Implementations may also override find_node to find the node to get the value from. Other methods are used to get values from nodes using heuristics and may not need to be overridden.

§Type Parameters

  • T - The type of the value to get.
  • N - The type of the node to get the value from.

§Examples

See the Getter implementations for Prompt for an example of how to implement this trait.

Required Methods§

source

fn get_value<'a>(&self, node: &'a dyn Node) -> Result<&'a T>

Gets a value from the given Node.

§Inputs
  • node - A reference to a Node.
§Returns

A reference to the value on success, or an error if the node could not be found.

source

fn get_value_mut<'a>(&self, node: &'a mut dyn Node) -> Result<&'a mut T>

Gets a value from the given Node.

§Inputs
  • node - A mutable reference to a Node.
§Returns

A mutable reference to the value on success, or an error if the node could not be found.

Provided Methods§

source

fn get<'a>(&self, prompt: &'a Prompt) -> Result<&'a T>

Uses a heuristic to find a Node and get the value from it.

§Inputs
  • prompt - A reference to a Prompt.
§Returns

A reference to the value on success, or an error if the node could not be found.

source

fn get_mut<'a>(&self, prompt: &'a mut Prompt) -> Result<&'a mut T>

Uses a heuristic to find a Node and get the value from it.

§Inputs
  • prompt - A mutable reference to a Prompt.
§Returns

A mutable reference to the value on success, or an error if the node could not be found.

source

fn get_from<'a>(&self, prompt: &'a Prompt, output_node: &str) -> Result<&'a T>

Finds a Node leading into the given output_node and gets the value from it.

§Inputs
  • prompt - A reference to a Prompt.
§Returns

A reference to the value on success, or an error if the node could not be found.

source

fn get_from_mut<'a>( &self, prompt: &'a mut Prompt, output_node: &str, ) -> Result<&'a mut T>

Finds a Node leading into the given output_node and gets the value from it.

§Inputs
  • prompt - A mutable reference to a Prompt.
§Returns

A mutable reference to the value on success, or an error if the node could not be found.

source

fn get_node<'a>(&self, prompt: &'a Prompt, node: &str) -> Result<&'a T>

Gets a value from the node with id node.

§Inputs
  • prompt - A reference to a Prompt.
  • node - The id of the node to set the value on.
§Returns

A reference to the value on success, or an error if the node could not be found.

source

fn get_node_mut<'a>( &self, prompt: &'a mut Prompt, node: &str, ) -> Result<&'a mut T>

Gets a value from the node with id node.

§Inputs
  • prompt - A mutable reference to a Prompt.
  • node - The id of the node to set the value on.
§Returns

A mutable reference to the value on success, or an error if the node could not be found.

source

fn find_node(prompt: &Prompt, output_node: Option<&str>) -> Option<String>

Finds a Node leading into the given output_node.

§Inputs
  • prompt - A mutable reference to a Prompt.
§Returns

The id of the node on success, or None if the node could not be found.

source

fn guess_node<'a>( prompt: &'a Prompt, output_node: Option<&str>, ) -> Option<&'a dyn Node>

Uses a heuristic to find a Node.

§Inputs
  • prompt - A reference to a Prompt.
  • output_node - The id of the node to search from.
§Returns

A reference to the node on success, or None if the node could not be found.

source

fn guess_node_mut<'a>( prompt: &'a mut Prompt, output_node: Option<&str>, ) -> Option<&'a mut dyn Node>

Uses a heuristic to find a Node.

§Inputs
  • prompt - A mutable reference to a Prompt.
  • output_node - The id of the node to search from.
§Returns

A mutable reference to the node on success, or None if the node could not be found.

Object Safety§

This trait is not object safe.

Implementors§