apb 0.2.2

Traits and types to handle ActivityPub objects
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#[derive(Debug, thiserror::Error)]
#[error("missing field '{0}'")]
pub struct FieldErr(pub &'static str);

pub type Field<T> = Result<T, FieldErr>;


// TODO this trait is really ad-hoc and has awful naming...

pub trait OptionalString {
	fn str(self) -> Option<String>;
}

impl OptionalString for Field<&str> {
	fn str(self) -> Option<String> {
		self.ok().map(|x| x.to_string())
	}
}