Skip to main content

Surfacable

Trait Surfacable 

Source
pub trait Surfacable {
    // Required method
    fn surface(&self) -> Result<Surface, SurfaceError>;
}
Expand description

A trait for objects that can generate a mathematical surface in 3D space.

This trait defines a single method, Surfacable::surface, which is responsible for calculating or constructing a Surface representation of the object that implements it. The surface may be created through direct construction or as the result of some computational process.

§Errors

The Surfacable::surface method returns a Result containing the generated surface on success. If an error occurs during the surface generation process, a SurfaceError is returned instead. Potential errors could include:

§Implementors

of this trait should define how their specific type generates a Surface. This could involve:

  • Utilizing existing 3D geometry to build the surface.
  • Analytical or procedural computations to construct a surface from data.
  • Interactions with external processes or datasets.

§See Also

For more details on specific error variants, refer to the SurfaceError enum. For details about the underlying mathematical representation, refer to the Surface struct.

§Example Use Cases

This trait can be used in scenarios where multiple types need to provide a unified interface for surface generation. For instance, different shapes (spheres, planes, or curves) may implement Surfacable so that they can all produce Surface outputs in a consistent manner.

  • crate::surfaces::surface: Contains the Surface structure and its related components.
  • crate::error::surfaces: Contains the SurfaceError type and its variants for error representation.

Required Methods§

Source

fn surface(&self) -> Result<Surface, SurfaceError>

  • surface():
    • Returns: Result<Surface, SurfaceError>
    • Description: Generates a surface or returns an error if something goes wrong during the process.
§Errors

Returns SurfaceError::ConstructionError when the implementor cannot produce any (x, y, z) sample (empty data source, degenerate axes, or missing metric), and propagates SurfaceError::Point3DError when a sample cannot be represented as a Point3D.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§