Skip to content

Commit 1bae4bb

Browse files
committed
chore: Remove depricated APIs
1 parent dbf01d1 commit 1bae4bb

3 files changed

Lines changed: 10 additions & 6 deletions

File tree

‎src/exchange_rates.rs‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,14 +222,18 @@ pub struct ExchangeRateHandler {
222222
pub source: ExchangeRateSource,
223223
}
224224

225-
impl fend_core::ExchangeRateFn for ExchangeRateHandler {
225+
impl fend_core::ExchangeRateFnV2 for ExchangeRateHandler {
226226
fn relative_to_base_currency(
227227
&self,
228228
currency: &str,
229+
options: &fend_core::ExchangeRateFnV2Options,
229230
) -> Result<f64, Box<dyn std::error::Error + Send + Sync + 'static>> {
230231
if !self.enable_internet_access {
231232
return Err(InternetAccessDisabledError.into());
232233
}
234+
if options.is_preview() {
235+
return Err(ExchangeRateSourceDisabledError.into());
236+
}
233237
let exchange_rates = get_exchange_rates(self.source)?;
234238
for (c, rate) in exchange_rates {
235239
if currency == c {

‎src/main.rs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl From<FendResult> for HistoryResult {
6060
Self {
6161
plain_result,
6262
spans,
63-
is_unit: result.is_unit_type(),
63+
is_empty: result.output_is_empty(),
6464
attrs: Attrs {
6565
trailing_newline: result.has_trailing_newline(),
6666
},
@@ -72,7 +72,7 @@ impl From<FendResult> for HistoryResult {
7272
pub struct HistoryResult {
7373
plain_result: String,
7474
spans: Vec<(std::ops::Range<usize>, fend_core::SpanKind)>,
75-
is_unit: bool, // is this the () type
75+
is_empty: bool, // is this the () type
7676
attrs: Attrs,
7777
}
7878
#[derive(Clone, Debug, PartialEq, Eq)]
@@ -120,7 +120,7 @@ impl HistoryResult {
120120
/// be useful to hide these values.
121121
#[must_use]
122122
pub fn is_unit_type(&self) -> bool {
123-
self.is_unit
123+
self.is_empty
124124
}
125125

126126
/// Returns whether or not the result should be outputted with a
@@ -143,7 +143,7 @@ fn app() -> Element {
143143
let mut context = use_signal(fend_core::Context::new);
144144
context.with_mut(|c| {
145145
let rates = exchange_rates.read();
146-
c.set_exchange_rate_handler_v1(*rates);
146+
c.set_exchange_rate_handler_v2(*rates);
147147
c.set_random_u32_fn(random_u32);
148148
});
149149

‎src/prompt.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub(crate) fn Prompt(
5454
..Default::default()
5555
}
5656
},
57-
if !preview.read().is_unit_type() {
57+
if !preview.read().output_is_empty() {
5858
label {
5959
color: "white",
6060
"{preview.read().get_main_result()}"

0 commit comments

Comments
 (0)