1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use crate::types::core::link::Link;
use crate::types::errors::TypeError;
use url::Url;
#[derive(Debug, PartialEq, Eq)]
pub struct Current(CurrentType);
impl Current {
pub fn new(value: CurrentType) -> Result<Self, TypeError> {
Ok(Self(value))
}
}
#[derive(Debug, PartialEq, Eq)]
pub enum CurrentType {
Url(Url),
Link(Link),
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_new() {
let t = Current::new(CurrentType::Url(
Url::try_from("https://example.org/foo").unwrap(),
));
assert!(t.is_ok());
assert_eq!(
t.unwrap(),
Current(CurrentType::Url(
Url::try_from("https://example.org/foo").unwrap(),
))
);
}
}