oanda_client/
environment.rs1use crate::{Error, Result};
4use url::Url;
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq)]
8pub enum Environment {
9 Practice,
11 Live,
13}
14
15impl Environment {
16 pub(crate) fn urls(self) -> Result<(Url, Url)> {
17 let (rest, stream) = match self {
18 Self::Practice => (
19 "https://api-fxpractice.oanda.com",
20 "https://stream-fxpractice.oanda.com",
21 ),
22 Self::Live => (
23 "https://api-fxtrade.oanda.com",
24 "https://stream-fxtrade.oanda.com",
25 ),
26 };
27 Ok((
28 Url::parse(rest).map_err(|e| Error::InvalidInput(e.to_string()))?,
29 Url::parse(stream).map_err(|e| Error::InvalidInput(e.to_string()))?,
30 ))
31 }
32}