use capnp_rpc::CapabilityServerSet; use crate::authorization::permissions::Permission; use api::auth_capnp::response::successful::Builder; use api::role_capnp; use crate::capnp::machinesystem::Machines; use crate::capnp::permissionsystem::Permissions; use crate::capnp::role::Role; use crate::capnp::user_system::Users; use crate::session::SessionHandle; pub struct APISession; impl APISession { pub fn new() -> Self { Self } pub fn build(session: SessionHandle, builder: Builder) { let mut builder = builder.init_session(); builder.reborrow().set_resources(capnp_rpc::new_client(Machines::new(session.clone()))); if session.has_perm(Permission::new("bffh.users.manage")) { let u = Users::new(session.clone()); builder.reborrow().set_users(capnp_rpc::new_client(u.clone())); } builder.set_permissions(capnp_rpc::new_client(Permissions::new(session))); } }