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:
Hocuri
2025-03-18 14:03:01 +01:00
committed by GitHub
parent 8fd972a2f9
commit 4a2bfe03da
10 changed files with 497 additions and 46 deletions

View File

@@ -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