DesignPattern

Enum DesignPattern 

Source
pub enum DesignPattern {
    Singleton {
        class: String,
        instance_method: String,
        instance_field: Option<String>,
        private_constructor: bool,
    },
    Factory {
        class: String,
        create_methods: Vec<String>,
        products: Vec<String>,
        is_abstract: bool,
    },
    Builder {
        class: String,
        build_method: String,
        setters: Vec<String>,
        target_type: Option<String>,
    },
    Adapter {
        class: String,
        adaptee: String,
        target_interface: Option<String>,
    },
    Decorator {
        class: String,
        base_interface: String,
        component_field: Option<String>,
    },
    Proxy {
        class: String,
        subject: String,
        proxy_type: Option<String>,
    },
    Observer {
        subject: String,
        observers: Vec<String>,
        notify_method: String,
        subscribe_methods: Vec<String>,
    },
    Strategy {
        interface: String,
        implementations: Vec<String>,
        context: Option<String>,
    },
    Command {
        interface: String,
        commands: Vec<String>,
        execute_method: String,
        has_undo: bool,
    },
    DependencyInjection {
        class: String,
        dependencies: Vec<(String, String)>,
    },
    Repository {
        class: String,
        entity_type: Option<String>,
        methods: Vec<String>,
    },
}
Expand description

Detected design pattern with associated metadata.

Variants§

§

Singleton

Singleton pattern: ensures a class has only one instance.

Heuristics:

  • Private/protected constructor
  • Static instance field
  • Static getter method (getInstance, instance, shared, etc.)

Fields

§class: String

The singleton class name.

§instance_method: String

Method name for getting the instance.

§instance_field: Option<String>

Instance field name (if detected).

§private_constructor: bool

Whether constructor is private.

§

Factory

Factory pattern: creates objects without specifying exact class.

Heuristics:

  • Method returns interface/abstract type
  • Creates different concrete types based on input
  • Named Factory or has create methods

Fields

§class: String

The factory class name.

§create_methods: Vec<String>

Factory method name(s).

§products: Vec<String>

Product types that can be created.

§is_abstract: bool

Whether it’s an abstract factory.

§

Builder

Builder pattern: constructs complex objects step by step.

Heuristics:

  • Method chaining (methods return self/Self)
  • Has build() or create() method
  • Setter-like methods

Fields

§class: String

The builder class name.

§build_method: String

The build/create method name.

§setters: Vec<String>

Setter/configuration methods.

§target_type: Option<String>

Target type being built (if detected).

§

Adapter

Adapter pattern: allows incompatible interfaces to work together.

Heuristics:

  • Wraps another class
  • Implements different interface than wrapped class
  • Delegates to wrapped object

Fields

§class: String

The adapter class name.

§adaptee: String

The adapted (wrapped) class.

§target_interface: Option<String>

Interface being adapted to.

§

Decorator

Decorator pattern: adds behavior to objects dynamically.

Heuristics:

  • Implements same interface as decorated object
  • Has reference to decorated object
  • Delegates most calls to decorated object

Fields

§class: String

The decorator class name.

§base_interface: String

Base interface/class being decorated.

§component_field: Option<String>

The decorated component field.

§

Proxy

Proxy pattern: provides a surrogate for another object.

Heuristics:

  • Same interface as real subject
  • Controls access to real subject
  • May add lazy loading, access control, logging

Fields

§class: String

The proxy class name.

§subject: String

The real subject class.

§proxy_type: Option<String>

Type of proxy (lazy, protection, remote, etc.).

§

Observer

Observer pattern: defines one-to-many dependency.

Heuristics:

  • Has collection of listeners/observers
  • Methods like add/remove/notify
  • Callback invocation pattern

Fields

§subject: String

The subject (observable) class.

§observers: Vec<String>

Observer interface or types.

§notify_method: String

Method for notifying observers.

§subscribe_methods: Vec<String>

Methods for subscribing/unsubscribing.

§

Strategy

Strategy pattern: defines family of interchangeable algorithms.

Heuristics:

  • Interface with multiple implementations
  • Strategy injected via constructor or setter
  • Context class uses strategy

Fields

§interface: String

The strategy interface name.

§implementations: Vec<String>

Concrete strategy implementations.

§context: Option<String>

Context class using the strategy.

§

Command

Command pattern: encapsulates request as an object.

Heuristics:

  • Has execute() or similar method
  • Encapsulates all info needed for action
  • Often with undo() support

Fields

§interface: String

The command interface name.

§commands: Vec<String>

Concrete command implementations.

§execute_method: String

Execute method name.

§has_undo: bool

Whether undo is supported.

§

DependencyInjection

Dependency Injection pattern (modern alternative to many patterns).

Heuristics:

  • Dependencies passed via constructor
  • Interface-typed parameters
  • No internal instantiation of dependencies

Fields

§class: String

Class using dependency injection.

§dependencies: Vec<(String, String)>

Injected dependencies (field name -> type).

§

Repository

Repository pattern: abstracts data access logic.

Heuristics:

  • Named *Repository
  • Has CRUD-like methods (find, save, delete)
  • Works with entity types

Fields

§class: String

The repository class name.

§entity_type: Option<String>

Entity type managed.

§methods: Vec<String>

CRUD methods present.

Implementations§

Source§

impl DesignPattern

Source

pub fn name(&self) -> &'static str

Get the human-readable name of the pattern.

Source

pub fn category(&self) -> PatternCategory

Get the category of this pattern.

Source

pub fn primary_class(&self) -> &str

Get the primary class/type name associated with this pattern.

Trait Implementations§

Source§

impl Clone for DesignPattern

Source§

fn clone(&self) -> DesignPattern

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for DesignPattern

Source§

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

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

impl<'de> Deserialize<'de> for DesignPattern

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for DesignPattern

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> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,