Struct icu::experimental::units::converter_factory::ConverterFactory
source · pub struct ConverterFactory { /* private fields */ }
Expand description
ConverterFactory is a factory for creating a converter.
Implementations§
source§impl ConverterFactory
impl ConverterFactory
sourcepub fn try_new_with_any_provider(
provider: &(impl AnyProvider + ?Sized),
) -> Result<ConverterFactory, DataError>
pub fn try_new_with_any_provider( provider: &(impl AnyProvider + ?Sized), ) -> Result<ConverterFactory, DataError>
A version of [Self :: new
] that uses custom data provided by an AnyProvider
.
sourcepub fn try_new_with_buffer_provider(
provider: &(impl BufferProvider + ?Sized),
) -> Result<ConverterFactory, DataError>
pub fn try_new_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), ) -> Result<ConverterFactory, DataError>
A version of [Self :: new
] that uses custom data provided by a BufferProvider
.
✨ Enabled with the serde
feature.
sourcepub const fn new() -> ConverterFactory
pub const fn new() -> ConverterFactory
Creates a new ConverterFactory
from compiled data.
✨ Enabled with the compiled_data
Cargo feature.
sourcepub fn try_new_unstable<D>(provider: &D) -> Result<ConverterFactory, DataError>
pub fn try_new_unstable<D>(provider: &D) -> Result<ConverterFactory, DataError>
A version of Self::new
that uses custom data provided by a DataProvider
.
pub fn parser(&self) -> MeasureUnitParser<'_>
sourcepub fn converter<T>(
&self,
input_unit: &MeasureUnit,
output_unit: &MeasureUnit,
) -> Option<UnitsConverter<T>>where
T: Convertible,
pub fn converter<T>(
&self,
input_unit: &MeasureUnit,
output_unit: &MeasureUnit,
) -> Option<UnitsConverter<T>>where
T: Convertible,
Creates a converter for converting between two single or compound units.
For example:
1 - meter
to foot
–> Simple
2 - kilometer-per-hour
to mile-per-hour
–> Compound
3 - mile-per-gallon
to liter-per-100-kilometer
–> Reciprocal
4 - celsius
to fahrenheit
–> Needs an offset
NOTE: This converter does not support conversions between mixed units, such as, from “meter” to “foot-and-inch”.
Auto Trait Implementations§
impl Freeze for ConverterFactory
impl RefUnwindSafe for ConverterFactory
impl Send for ConverterFactory
impl Sync for ConverterFactory
impl Unpin for ConverterFactory
impl UnwindSafe for ConverterFactory
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
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 more