shared::utils::fragment_task_impl

Trait FragmentTaskOperation

Source
pub trait FragmentTaskOperation {
    // Required methods
    fn new(
        id: U8Data,
        fractal: FractalDescriptor,
        max_iteration: u16,
        resolution: Resolution,
        range: Range,
    ) -> Self;
    fn serialize(&self) -> Result<String, Error>;
    fn deserialize(message: &str) -> Result<Self, Error>
       where Self: Sized;
}

Required Methods§

Source

fn new( id: U8Data, fractal: FractalDescriptor, max_iteration: u16, resolution: Resolution, range: Range, ) -> Self

Source

fn serialize(&self) -> Result<String, Error>

Serializes a FragmentTask into a JSON string.

This function takes a reference to a FragmentTask and converts it into a JSON string using serde_json. The serialization captures detailed information about the fractal task, including the type of fractal (Julia or IteratedSinZ), various parameters of the fractal, the maximum iteration count, resolution, and the range for the task.

§Arguments
  • request - A reference to the FragmentTask to be serialized.
§Returns

A Result<String, serde_json::Error> which is Ok containing the JSON string if serialization is successful, or an Err containing the serde_json::Error if it fails.

Source

fn deserialize(message: &str) -> Result<Self, Error>
where Self: Sized,

Deserializes a JSON string into a FragmentTask.

This function takes a string slice that holds the JSON representation of the FragmentTask and converts it into a FragmentTask using serde_json. The deserialization captures detailed information about the fractal task, including the type of fractal (Julia or IteratedSinZ), various parameters of the fractal, the maximum iteration count, resolution, and the range for the task.

§Arguments
  • response - A string slice that holds the JSON representation of the FragmentTask.
§Returns

A Result<FragmentTask, serde_json::Error> which is Ok containing the FragmentTask if deserialization is successful,

or an Err containing the serde_json::Error if it fails.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§