mirror of
https://gitlab.com/fabinfra/fabaccess/bffh.git
synced 2024-11-23 23:27:57 +01:00
40 lines
1.4 KiB
Rust
40 lines
1.4 KiB
Rust
use capnp::capability::Promise;
|
|
use capnp::Error;
|
|
use capnp_rpc::pry;
|
|
use crate::oid;
|
|
use crate::utils::oid::ObjectIdentifier;
|
|
use api::traits::claimable_capnp::trait_claimable;
|
|
use api::traits::claimable_capnp::trait_claimable::{GetStateParams, GetStateResults};
|
|
use api::traits_capnp::trait_super::{GetNameParams, GetNameResults, Server};
|
|
use api::schema::utils_capnp::map::entry as api_map;
|
|
|
|
pub const CLAIMABLE_TRAIT_ID: ObjectIdentifier = oid!(1.3.6.1.4.1.61783.612.1.0);
|
|
|
|
pub struct ClaimableServer {
|
|
|
|
}
|
|
|
|
impl ClaimableServer {
|
|
pub fn insert_into_map(self, mut builder: api_map::Builder<capnp::data::Owned, capnp::any_pointer::Owned>) -> Result<(), capnp::Error> {
|
|
builder.set_key(CLAIMABLE_TRAIT_ID.as_bytes())?;
|
|
let client: trait_claimable::Client = capnp_rpc::new_client(self);
|
|
let mut cap_builder = builder.init_value();
|
|
cap_builder.set_as_capability(client.client.hook);
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
impl Server for ClaimableServer {
|
|
fn get_name(&mut self, _: GetNameParams, mut result: GetNameResults) -> Promise<(), Error> {
|
|
result.get().set_name("Claimable");
|
|
Promise::ok(())
|
|
}
|
|
}
|
|
|
|
impl trait_claimable::Server for ClaimableServer {
|
|
fn get_state(&mut self, _: GetStateParams, mut results: GetStateResults) -> Promise<(), Error> {
|
|
let mut builder = pry!(results.get().get_claims());
|
|
|
|
Promise::ok(())
|
|
}
|
|
} |