Skip to main content

PrimalityRegistry

Struct PrimalityRegistry 

Source
pub struct PrimalityRegistry<N: PrimInt> { /* private fields */ }
Expand description

Registry for managing and comparing primality testing algorithms

The registry maintains a collection of algorithm implementations and provides convenient methods for registering new algorithms and accessing them by name.

Implementations§

Source§

impl<N: PrimInt + ToPrimitive + FromPrimitive + Unsigned> PrimalityRegistry<N>

Source

pub fn new() -> Self

Creates a new empty registry

Use this if you want to manually register specific algorithms. To get all registered algorithms at once, use with_all_algorithms().

Source

pub fn with_all_algorithms() -> Self

Creates a registry with all available algorithms

This is the recommended way to create a registry if you want to use all implemented algorithms.

Source

pub fn register<T: PrimalityTest<N> + 'static>(&mut self, algo: T)

Registers a new primality test algorithm

§Arguments
  • algo - The algorithm to register, must implement PrimalityTest
Source

pub fn algorithms(&self) -> &[Box<dyn PrimalityTest<N>>]

Returns a slice of all registered algorithms

Source

pub fn get_by_name(&self, name: &str) -> Option<&Box<dyn PrimalityTest<N>>>

Finds an algorithm by its name

§Arguments
  • name - The name of the algorithm to find
§Returns

Some reference to the algorithm if found, None otherwise

Trait Implementations§

Source§

impl<N: PrimInt + ToPrimitive + FromPrimitive + Unsigned> Default for PrimalityRegistry<N>

Source§

fn default() -> Self

Returns the “default value” for a type. 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.