parent
bef845147d
commit
5e99de6ea0
@ -0,0 +1,39 @@ |
||||
//! libqaul RPC compatibility adapter
|
||||
//!
|
||||
//! By default `libqaul` is only meant to be used by local Rust
|
||||
//! clients. To allow third-party clients to also interact with a
|
||||
//! running stack, you should use the qrpc bus. This module exposes
|
||||
//! some utilities to bind libqaul functions to an rpc server.
|
||||
//!
|
||||
//! To write a service to use libqaul, include the client-lib
|
||||
//! (libqaul-rpc) for type and API configuration.
|
||||
|
||||
use crate::QaulRef; |
||||
use qrpc_sdk::{default_socket_path, error::RpcResult, RpcSocket, Service}; |
||||
use async_std::sync::Arc; |
||||
|
||||
/// A pluggable RPC server that wraps around libqaul
|
||||
///
|
||||
/// Initialise this server with a fully initialised [`Qaul`] instance.
|
||||
/// You will lose access to this type once you start the RPC server.
|
||||
/// Currently there is no self-management interface available via
|
||||
/// qrpc.
|
||||
///
|
||||
pub struct RpcServer { |
||||
inner: QaulRef, |
||||
socket: Arc<RpcSocket>, |
||||
} |
||||
|
||||
impl RpcServer { |
||||
/// Wrapper around `new` with `default_socket_path()`
|
||||
pub async fn start_default(inner: QaulRef) -> RpcResult<Self> { |
||||
let (addr, port) = default_socket_path(); |
||||
Self::new(inner, addr, port).await |
||||
} |
||||
|
||||
pub async fn new(inner: QaulRef, addr: &str, port: u16) -> RpcResult<Self> { |
||||
let socket = RpcSocket::connect(addr, port).await?; |
||||
let _self = Self { inner, socket }; |
||||
Ok(_self) |
||||
} |
||||
} |
@ -0,0 +1,87 @@ |
||||
struct UserAuth { |
||||
id @0 :Text; |
||||
token @1 :Text; |
||||
} |
||||
|
||||
struct ContactQuery { |
||||
union { |
||||
nick @0 :Text; |
||||
trust :group { |
||||
val @1 :Int8; |
||||
fuz @2 :Int8; |
||||
} |
||||
met @3 :Bool; |
||||
location @4 :Text; |
||||
notes @5 :Text; |
||||
} |
||||
} |
||||
|
||||
struct Mode { |
||||
union { |
||||
flood @0 :Void; |
||||
std @1 :Text; |
||||
} |
||||
} |
||||
|
||||
struct IdType { |
||||
union { |
||||
unique @0 :Void; |
||||
grouped @1 :Text; |
||||
} |
||||
} |
||||
|
||||
struct SeviceId { |
||||
union { |
||||
# It's one of the most common passwords after all |
||||
god @0 :Void; |
||||
id @1 :Text; |
||||
} |
||||
} |
||||
|
||||
struct Tag { |
||||
key @0 :Text; |
||||
val @1 :Data; |
||||
} |
||||
|
||||
struct TagSet { |
||||
tags @0 :List(Tag); |
||||
} |
||||
|
||||
struct MsgQuery { |
||||
id @0 :Text; |
||||
sender @1 :Text; |
||||
tags @2 :TagSet; |
||||
skip @3 :UInt; |
||||
} |
||||
|
||||
struct MetadataMap { |
||||
name @0 :Text; |
||||
map @1 :List(Entry); |
||||
|
||||
struct Entry { |
||||
key @0 :Text; |
||||
val @1 :Data; |
||||
} |
||||
} |
||||
|
||||
struct SetDiff(Val) { |
||||
union { |
||||
set @0 :Val; |
||||
unset @0 :Val; |
||||
} |
||||
} |
||||
|
||||
struct UserUpdate { |
||||
handle @0 :Text; |
||||
disp_name @1 :Text; |
||||
add_to_bio @2 :List(BioLine); |
||||
rm_fr_bio @3 :List(Text); |
||||
add_serv @4 :Text; |
||||
rm_serv @5 :Text; |
||||
avi_data @6 :SetDiff(Data); |
||||
|
||||
struct BioLine { |
||||
key @0 :Text; |
||||
val @1 :Text; |
||||
} |
||||
} |
@ -0,0 +1,29 @@ |
||||
# libqaul api scopes |
||||
|
||||
* contacts |
||||
* modify(userauth, contact-id, lambda) |
||||
* get(userauth, contact-id) |
||||
* query(userauth, contact query) |
||||
* all(userauth) |
||||
* messages |
||||
* send(userauth, mode, id_type, into service, into tagset, payload (vec u8)) |
||||
* subscribe(userauth, into service, into tagset) |
||||
* query(userauth, into service, msgquery) |
||||
* services |
||||
* register(service name, callback(service event)) |
||||
* unregister(name) |
||||
* save(userauth, into service, metadata map, into tagset) |
||||
* delete(userauth, into service, into key) |
||||
* query(userauth, into service, into tagset) |
||||
* users |
||||
* list() |
||||
* list_remote() (???) |
||||
* is_authenticated(userauth) |
||||
* create(password) |
||||
* delete(userauth) |
||||
* change_pw(userauth, new password) |
||||
* login(user id, password) |
||||
* logout(userauth) |
||||
* get(user id) |
||||
* update(userauth, user update) |
||||
|
Loading…
Reference in new issue