mirror of
https://github.com/chatmail/core.git
synced 2026-04-18 22:16:30 +03:00
api: Sketch add_transport_from_qr(), add_transport(), list_transports(), delete_transport() APIs (#6589)
Four new APIs `add_transport_from_qr()`, `add_transport()`, `list_transports()`, `delete_transport()`, as described in the draft at "API". The `add_tranport*()` APIs automatically stops and starts I/O; for `configure()` the stopping and starting is done in the JsonRPC bindings, which is not where things like this should be done I think, the bindings should just translate the APIs. This also completely disables AEAP for now. I won't be available for a week, but if you want to merge this already, feel free to just commit all review suggestions and squash-merge.
This commit is contained in:
30
src/tools.rs
30
src/tools.rs
@@ -603,6 +603,36 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) trait ToOption<T> {
|
||||
fn to_option(self) -> Option<T>;
|
||||
}
|
||||
impl<'a> ToOption<&'a str> for &'a String {
|
||||
fn to_option(self) -> Option<&'a str> {
|
||||
if self.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
impl ToOption<String> for u16 {
|
||||
fn to_option(self) -> Option<String> {
|
||||
if self == 0 {
|
||||
None
|
||||
} else {
|
||||
Some(self.to_string())
|
||||
}
|
||||
}
|
||||
}
|
||||
impl ToOption<String> for Option<i32> {
|
||||
fn to_option(self) -> Option<String> {
|
||||
match self {
|
||||
None | Some(0) => None,
|
||||
Some(v) => Some(v.to_string()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn remove_subject_prefix(last_subject: &str) -> String {
|
||||
let subject_start = if last_subject.starts_with("Chat:") {
|
||||
0
|
||||
|
||||
Reference in New Issue
Block a user