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<Self, DataError>
pub fn try_new_with_any_provider( provider: &(impl AnyProvider + ?Sized), ) -> Result<Self, 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<Self, DataError>
pub fn try_new_with_buffer_provider( provider: &(impl BufferProvider + ?Sized), ) -> Result<Self, DataError>
A version of [Self :: new
] that uses custom data provided by a BufferProvider
.
✨ Enabled with the serde
feature.
sourcepub const fn new() -> Self
pub const fn new() -> Self
Creates a new ConverterFactory
from compiled data.
✨ Enabled with the compiled_data
Cargo feature.
sourcepub fn try_new_unstable<D>(provider: &D) -> Result<Self, DataError>where
D: ?Sized + DataProvider<UnitsInfoV1Marker>,
pub fn try_new_unstable<D>(provider: &D) -> Result<Self, DataError>where
D: ?Sized + DataProvider<UnitsInfoV1Marker>,
A version of Self::new
that uses custom data provided by a DataProvider
.
pub fn parser(&self) -> MeasureUnitParser<'_>
sourcepub fn converter<T: Convertible>(
&self,
input_unit: &MeasureUnit,
output_unit: &MeasureUnit,
) -> Option<UnitsConverter<T>>
pub fn converter<T: Convertible>( &self, input_unit: &MeasureUnit, output_unit: &MeasureUnit, ) -> Option<UnitsConverter<T>>
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