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
impl TransformRegistry
Sourcepub fn new() -> TransformRegistry
pub fn new() -> TransformRegistry
Creates a new empty registry.
§Examples
use oar_ocr_core::core::config::transform::TransformRegistry;
let registry = TransformRegistry::new();
assert_eq!(registry.len(), 0);Sourcepub fn add(&mut self, transform_type: TransformType, config: TransformConfig)
pub fn add(&mut self, transform_type: TransformType, config: TransformConfig)
Adds a transform to the registry.
§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);Sourcepub fn remove(&mut self, transform_type: &TransformType) -> usize
pub fn remove(&mut self, transform_type: &TransformType) -> usize
Removes all transforms of the given type, returning how many were removed.
Sourcepub fn iter(&self) -> Iter<'_, (TransformType, TransformConfig)>
pub fn iter(&self) -> Iter<'_, (TransformType, TransformConfig)>
Returns an iterator over the (type, config) transforms.
Sourcepub fn iter_mut(&mut self) -> IterMut<'_, (TransformType, TransformConfig)>
pub fn iter_mut(&mut self) -> IterMut<'_, (TransformType, TransformConfig)>
Returns a mutable iterator over the (type, config) transforms.
Sourcepub fn contains(&self, transform_type: &TransformType) -> bool
pub fn contains(&self, transform_type: &TransformType) -> bool
Returns true if the registry contains a transform of the given type.
Sourcepub fn get_all(&self, transform_type: &TransformType) -> Vec<&TransformConfig>
pub fn get_all(&self, transform_type: &TransformType) -> Vec<&TransformConfig>
Returns all configs for transforms of the given type.
Sourcepub fn get_first(
&self,
transform_type: &TransformType,
) -> Option<&TransformConfig>
pub fn get_first( &self, transform_type: &TransformType, ) -> Option<&TransformConfig>
Returns the config for the first transform of the given type, if any.
Trait Implementations§
Source§impl Debug for TransformRegistry
impl Debug for TransformRegistry
Source§impl Default for TransformRegistry
impl Default for TransformRegistry
Source§fn default() -> TransformRegistry
fn default() -> TransformRegistry
This allows TransformRegistry to be created with default values.
Source§impl IntoIterator for TransformRegistry
impl IntoIterator for TransformRegistry
Source§fn into_iter(self) -> <TransformRegistry as IntoIterator>::IntoIter
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)
type Item = (TransformType, TransformConfig)
Source§type IntoIter = IntoIter<<TransformRegistry as IntoIterator>::Item>
type IntoIter = IntoIter<<TransformRegistry as IntoIterator>::Item>
Source§impl<'a> IntoIterator for &'a TransformRegistry
impl<'a> IntoIterator for &'a TransformRegistry
Source§fn into_iter(self) -> <&'a TransformRegistry as IntoIterator>::IntoIter
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)
type Item = &'a (TransformType, TransformConfig)
Source§type IntoIter = Iter<'a, (TransformType, TransformConfig)>
type IntoIter = Iter<'a, (TransformType, TransformConfig)>
Source§impl<'a> IntoIterator for &'a mut TransformRegistry
impl<'a> IntoIterator for &'a mut TransformRegistry
Source§fn into_iter(self) -> <&'a mut TransformRegistry as IntoIterator>::IntoIter
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)
type Item = &'a mut (TransformType, TransformConfig)
Source§type IntoIter = IterMut<'a, (TransformType, TransformConfig)>
type IntoIter = IterMut<'a, (TransformType, TransformConfig)>
Auto Trait Implementations§
impl Freeze for TransformRegistry
impl RefUnwindSafe for TransformRegistry
impl Send for TransformRegistry
impl Sync for TransformRegistry
impl Unpin for TransformRegistry
impl UnsafeUnpin for TransformRegistry
impl UnwindSafe for TransformRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.