Skip to main content

TransformRegistry

Struct TransformRegistry 

Source
pub struct TransformRegistry { /* private fields */ }
Expand description

A registry for managing transform configurations.

This struct provides a way to register and manage multiple transform configurations that can be applied to images in sequence.

Implementations§

Source§

impl TransformRegistry

Source

pub fn new() -> TransformRegistry

Creates a new empty TransformRegistry.

§Returns

A new empty TransformRegistry.

§Examples
use oar_ocr_core::core::config::transform::TransformRegistry;

let registry = TransformRegistry::new();
assert_eq!(registry.len(), 0);
Source

pub fn add(&mut self, transform_type: TransformType, config: TransformConfig)

Adds a transform to the registry.

§Arguments
  • transform_type - The type of transform to add.
  • config - The configuration for the transform.
§Examples
use oar_ocr_core::core::config::transform::{TransformRegistry, TransformType, TransformConfig};

let mut registry = TransformRegistry::new();
registry.add(TransformType::ResizeImage, TransformConfig::ResizeImage {
    width: Some(224),
    height: Some(224),
    shorter_side: None,
    longer_side: None,
    maintain_aspect_ratio: Some(false),
    interpolation: None,
});
assert_eq!(registry.len(), 1);
Source

pub fn remove(&mut self, transform_type: &TransformType) -> usize

Removes all transforms of a specific type from the registry.

§Arguments
  • transform_type - The type of transform to remove.
§Returns

The number of transforms removed.

Source

pub fn len(&self) -> usize

Gets the number of transforms in the registry.

§Returns

The number of transforms in the registry.

Source

pub fn is_empty(&self) -> bool

Checks if the registry is empty.

§Returns

True if the registry is empty, false otherwise.

Source

pub fn clear(&mut self)

Clears all transforms from the registry.

Source

pub fn iter(&self) -> Iter<'_, (TransformType, TransformConfig)>

Gets an iterator over the transforms in the registry.

§Returns

An iterator over tuples of (TransformType, TransformConfig).

Source

pub fn iter_mut(&mut self) -> IterMut<'_, (TransformType, TransformConfig)>

Gets a mutable iterator over the transforms in the registry.

§Returns

A mutable iterator over tuples of (TransformType, TransformConfig).

Source

pub fn contains(&self, transform_type: &TransformType) -> bool

Checks if the registry contains a specific transform type.

§Arguments
  • transform_type - The type of transform to check for.
§Returns

True if the registry contains the transform type, false otherwise.

Source

pub fn get_all(&self, transform_type: &TransformType) -> Vec<&TransformConfig>

Gets all transforms of a specific type.

§Arguments
  • transform_type - The type of transform to get.
§Returns

A vector of references to the configurations for the specified transform type.

Source

pub fn get_first( &self, transform_type: &TransformType, ) -> Option<&TransformConfig>

Gets the first transform of a specific type.

§Arguments
  • transform_type - The type of transform to get.
§Returns

An optional reference to the configuration for the first transform of the specified type.

Trait Implementations§

Source§

impl Debug for TransformRegistry

Source§

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

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

impl Default for TransformRegistry

Source§

fn default() -> TransformRegistry

This allows TransformRegistry to be created with default values.

Source§

impl<'a> IntoIterator for &'a TransformRegistry

Source§

fn into_iter(self) -> <&'a TransformRegistry as IntoIterator>::IntoIter

This allows &TransformRegistry to be used in for loops and other iterator contexts.

Source§

type Item = &'a (TransformType, TransformConfig)

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, (TransformType, TransformConfig)>

Which kind of iterator are we turning this into?
Source§

impl<'a> IntoIterator for &'a mut TransformRegistry

Source§

fn into_iter(self) -> <&'a mut TransformRegistry as IntoIterator>::IntoIter

This allows &mut TransformRegistry to be used in for loops and other iterator contexts.

Source§

type Item = &'a mut (TransformType, TransformConfig)

The type of the elements being iterated over.
Source§

type IntoIter = IterMut<'a, (TransformType, TransformConfig)>

Which kind of iterator are we turning this into?
Source§

impl IntoIterator for TransformRegistry

Source§

fn into_iter(self) -> <TransformRegistry as IntoIterator>::IntoIter

This allows TransformRegistry to be used in for loops and other iterator contexts.

Source§

type Item = (TransformType, TransformConfig)

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<<TransformRegistry as IntoIterator>::Item>

Which kind of iterator are we turning this into?

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> 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> 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<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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