Add user search impl

This commit is contained in:
Nadja Reitzenstein 2022-04-28 20:33:46 +02:00
parent b6c9b61511
commit 869f3d5e5f
5 changed files with 825 additions and 30 deletions

View File

@ -487,3 +487,213 @@ pub mod optional { /* T */
pub type WhichReader<'a,T> = Which<::capnp::Result<<T as ::capnp::traits::Owned<'a>>::Reader>>;
pub type WhichBuilder<'a,T> = Which<::capnp::Result<<T as ::capnp::traits::Owned<'a>>::Builder>>;
}
pub mod fallible { /* T,E */
pub use self::Which::{Failed,Successful};
#[derive(Copy, Clone)]
pub struct Owned<T,E> {
_phantom: ::core::marker::PhantomData<(T,E)>
}
impl <'a, T,E> ::capnp::traits::Owned<'a> for Owned <T,E> where T: for<'c> ::capnp::traits::Owned<'c>, E: for<'c> ::capnp::traits::Owned<'c> { type Reader = Reader<'a, T,E>; type Builder = Builder<'a, T,E>; }
impl <'a, T,E> ::capnp::traits::OwnedStruct<'a> for Owned <T,E> where T: for<'c> ::capnp::traits::Owned<'c>, E: for<'c> ::capnp::traits::Owned<'c> { type Reader = Reader<'a, T,E>; type Builder = Builder<'a, T,E>; }
impl <T,E> ::capnp::traits::Pipelined for Owned<T,E> where T: for<'c> ::capnp::traits::Owned<'c>, E: for<'c> ::capnp::traits::Owned<'c> { type Pipeline = Pipeline<T,E>; }
#[derive(Clone, Copy)]
pub struct Reader<'a,T,E> where T: for<'c> ::capnp::traits::Owned<'c>, E: for<'c> ::capnp::traits::Owned<'c> {
reader: ::capnp::private::layout::StructReader<'a>,
_phantom: ::core::marker::PhantomData<(T,E)>
}
impl <'a,T,E> ::capnp::traits::HasTypeId for Reader<'a,T,E> where T: for<'c> ::capnp::traits::Owned<'c>, E: for<'c> ::capnp::traits::Owned<'c> {
#[inline]
fn type_id() -> u64 { _private::TYPE_ID }
}
impl <'a,T,E> ::capnp::traits::FromStructReader<'a> for Reader<'a,T,E> where T: for<'c> ::capnp::traits::Owned<'c>, E: for<'c> ::capnp::traits::Owned<'c> {
fn new(reader: ::capnp::private::layout::StructReader<'a>) -> Reader<'a,T,E> {
Reader { reader, _phantom: ::core::marker::PhantomData, }
}
}
impl <'a,T,E> ::capnp::traits::FromPointerReader<'a> for Reader<'a,T,E> where T: for<'c> ::capnp::traits::Owned<'c>, E: for<'c> ::capnp::traits::Owned<'c> {
fn get_from_pointer(reader: &::capnp::private::layout::PointerReader<'a>, default: ::core::option::Option<&'a [capnp::Word]>) -> ::capnp::Result<Reader<'a,T,E>> {
::core::result::Result::Ok(::capnp::traits::FromStructReader::new(reader.get_struct(default)?))
}
}
impl <'a,T,E> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,T,E> where T: for<'c> ::capnp::traits::Owned<'c>, E: for<'c> ::capnp::traits::Owned<'c> {
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
self.reader
}
}
impl <'a,T,E> ::capnp::traits::Imbue<'a> for Reader<'a,T,E> where T: for<'c> ::capnp::traits::Owned<'c>, E: for<'c> ::capnp::traits::Owned<'c> {
fn imbue(&mut self, cap_table: &'a ::capnp::private::layout::CapTable) {
self.reader.imbue(::capnp::private::layout::CapTableReader::Plain(cap_table))
}
}
impl <'a,T,E> Reader<'a,T,E> where T: for<'c> ::capnp::traits::Owned<'c>, E: for<'c> ::capnp::traits::Owned<'c> {
pub fn reborrow(&self) -> Reader<'_,T,E> {
Reader { .. *self }
}
pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> {
self.reader.total_size()
}
pub fn has_failed(&self) -> bool {
if self.reader.get_data_field::<u16>(0) != 0 { return false; }
!self.reader.get_pointer_field(0).is_null()
}
pub fn has_successful(&self) -> bool {
if self.reader.get_data_field::<u16>(0) != 1 { return false; }
!self.reader.get_pointer_field(0).is_null()
}
#[inline]
pub fn which(self) -> ::core::result::Result<WhichReader<'a,T,E>, ::capnp::NotInSchema> {
match self.reader.get_data_field::<u16>(0) {
0 => {
::core::result::Result::Ok(Failed(
::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(0), ::core::option::Option::None)
))
}
1 => {
::core::result::Result::Ok(Successful(
::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(0), ::core::option::Option::None)
))
}
x => ::core::result::Result::Err(::capnp::NotInSchema(x))
}
}
}
pub struct Builder<'a,T,E> where T: for<'c> ::capnp::traits::Owned<'c>, E: for<'c> ::capnp::traits::Owned<'c> {
builder: ::capnp::private::layout::StructBuilder<'a>,
_phantom: ::core::marker::PhantomData<(T,E)>
}
impl <'a,T,E> ::capnp::traits::HasStructSize for Builder<'a,T,E> where T: for<'c> ::capnp::traits::Owned<'c>, E: for<'c> ::capnp::traits::Owned<'c> {
#[inline]
fn struct_size() -> ::capnp::private::layout::StructSize { _private::STRUCT_SIZE }
}
impl <'a,T,E> ::capnp::traits::HasTypeId for Builder<'a,T,E> where T: for<'c> ::capnp::traits::Owned<'c>, E: for<'c> ::capnp::traits::Owned<'c> {
#[inline]
fn type_id() -> u64 { _private::TYPE_ID }
}
impl <'a,T,E> ::capnp::traits::FromStructBuilder<'a> for Builder<'a,T,E> where T: for<'c> ::capnp::traits::Owned<'c>, E: for<'c> ::capnp::traits::Owned<'c> {
fn new(builder: ::capnp::private::layout::StructBuilder<'a>) -> Builder<'a, T,E> {
Builder { builder, _phantom: ::core::marker::PhantomData, }
}
}
impl <'a,T,E> ::capnp::traits::ImbueMut<'a> for Builder<'a,T,E> where T: for<'c> ::capnp::traits::Owned<'c>, E: for<'c> ::capnp::traits::Owned<'c> {
fn imbue_mut(&mut self, cap_table: &'a mut ::capnp::private::layout::CapTable) {
self.builder.imbue(::capnp::private::layout::CapTableBuilder::Plain(cap_table))
}
}
impl <'a,T,E> ::capnp::traits::FromPointerBuilder<'a> for Builder<'a,T,E> where T: for<'c> ::capnp::traits::Owned<'c>, E: for<'c> ::capnp::traits::Owned<'c> {
fn init_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>, _size: u32) -> Builder<'a,T,E> {
::capnp::traits::FromStructBuilder::new(builder.init_struct(_private::STRUCT_SIZE))
}
fn get_from_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>, default: ::core::option::Option<&'a [capnp::Word]>) -> ::capnp::Result<Builder<'a,T,E>> {
::core::result::Result::Ok(::capnp::traits::FromStructBuilder::new(builder.get_struct(_private::STRUCT_SIZE, default)?))
}
}
impl <'a,T,E> ::capnp::traits::SetPointerBuilder for Reader<'a,T,E> where T: for<'c> ::capnp::traits::Owned<'c>, E: for<'c> ::capnp::traits::Owned<'c> {
fn set_pointer_builder<'b>(pointer: ::capnp::private::layout::PointerBuilder<'b>, value: Reader<'a,T,E>, canonicalize: bool) -> ::capnp::Result<()> { pointer.set_struct(&value.reader, canonicalize) }
}
impl <'a,T,E> Builder<'a,T,E> where T: for<'c> ::capnp::traits::Owned<'c>, E: for<'c> ::capnp::traits::Owned<'c> {
pub fn into_reader(self) -> Reader<'a,T,E> {
::capnp::traits::FromStructReader::new(self.builder.into_reader())
}
pub fn reborrow(&mut self) -> Builder<'_,T,E> {
Builder { .. *self }
}
pub fn reborrow_as_reader(&self) -> Reader<'_,T,E> {
::capnp::traits::FromStructReader::new(self.builder.into_reader())
}
pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> {
self.builder.into_reader().total_size()
}
#[inline]
pub fn initn_failed(self, length: u32) -> <E as ::capnp::traits::Owned<'a>>::Builder {
self.builder.set_data_field::<u16>(0, 0);
::capnp::any_pointer::Builder::new(self.builder.get_pointer_field(0)).initn_as(length)
}
#[inline]
pub fn set_failed(&mut self, value: <E as ::capnp::traits::Owned<'_>>::Reader) -> ::capnp::Result<()> {
self.builder.set_data_field::<u16>(0, 0);
::capnp::traits::SetPointerBuilder::set_pointer_builder(self.builder.get_pointer_field(0), value, false)
}
#[inline]
pub fn init_failed(self, ) -> <E as ::capnp::traits::Owned<'a>>::Builder {
self.builder.set_data_field::<u16>(0, 0);
::capnp::any_pointer::Builder::new(self.builder.get_pointer_field(0)).init_as()
}
pub fn has_failed(&self) -> bool {
if self.builder.get_data_field::<u16>(0) != 0 { return false; }
!self.builder.get_pointer_field(0).is_null()
}
#[inline]
pub fn initn_successful(self, length: u32) -> <T as ::capnp::traits::Owned<'a>>::Builder {
self.builder.set_data_field::<u16>(0, 1);
::capnp::any_pointer::Builder::new(self.builder.get_pointer_field(0)).initn_as(length)
}
#[inline]
pub fn set_successful(&mut self, value: <T as ::capnp::traits::Owned<'_>>::Reader) -> ::capnp::Result<()> {
self.builder.set_data_field::<u16>(0, 1);
::capnp::traits::SetPointerBuilder::set_pointer_builder(self.builder.get_pointer_field(0), value, false)
}
#[inline]
pub fn init_successful(self, ) -> <T as ::capnp::traits::Owned<'a>>::Builder {
self.builder.set_data_field::<u16>(0, 1);
::capnp::any_pointer::Builder::new(self.builder.get_pointer_field(0)).init_as()
}
pub fn has_successful(&self) -> bool {
if self.builder.get_data_field::<u16>(0) != 1 { return false; }
!self.builder.get_pointer_field(0).is_null()
}
#[inline]
pub fn which(self) -> ::core::result::Result<WhichBuilder<'a,T,E>, ::capnp::NotInSchema> {
match self.builder.get_data_field::<u16>(0) {
0 => {
::core::result::Result::Ok(Failed(
::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(0), ::core::option::Option::None)
))
}
1 => {
::core::result::Result::Ok(Successful(
::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(0), ::core::option::Option::None)
))
}
x => ::core::result::Result::Err(::capnp::NotInSchema(x))
}
}
}
pub struct Pipeline<T,E> {
_typeless: ::capnp::any_pointer::Pipeline,
_phantom: ::core::marker::PhantomData<(T,E)>
}
impl<T,E> ::capnp::capability::FromTypelessPipeline for Pipeline<T,E> {
fn new(typeless: ::capnp::any_pointer::Pipeline) -> Pipeline<T,E> {
Pipeline { _typeless: typeless, _phantom: ::core::marker::PhantomData, }
}
}
impl<T,E> Pipeline<T,E> where T: ::capnp::traits::Pipelined, <T as ::capnp::traits::Pipelined>::Pipeline: ::capnp::capability::FromTypelessPipeline, E: ::capnp::traits::Pipelined, <E as ::capnp::traits::Pipelined>::Pipeline: ::capnp::capability::FromTypelessPipeline {
}
mod _private {
use capnp::private::layout;
pub const STRUCT_SIZE: layout::StructSize = layout::StructSize { data: 1, pointers: 1 };
pub const TYPE_ID: u64 = 0xf477_aafa_9205_11aa;
}
pub enum Which<A0,A1> {
Failed(A0),
Successful(A1),
}
pub type WhichReader<'a,T,E> = Which<::capnp::Result<<E as ::capnp::traits::Owned<'a>>::Reader>,::capnp::Result<<T as ::capnp::traits::Owned<'a>>::Reader>>;
pub type WhichBuilder<'a,T,E> = Which<::capnp::Result<<E as ::capnp::traits::Owned<'a>>::Builder>,::capnp::Result<<T as ::capnp::traits::Owned<'a>>::Builder>>;
}

View File

@ -57,6 +57,10 @@ pub mod user_system {
pub fn get_manage(self) -> ::capnp::Result<crate::schema::usersystem_capnp::user_system::manage::Client> {
match self.reader.get_pointer_field(1).get_capability() { ::core::result::Result::Ok(c) => ::core::result::Result::Ok(::capnp::capability::FromClientHook::new(c)), ::core::result::Result::Err(e) => ::core::result::Result::Err(e)}
}
#[inline]
pub fn get_search(self) -> ::capnp::Result<crate::schema::usersystem_capnp::user_system::search::Client> {
match self.reader.get_pointer_field(2).get_capability() { ::core::result::Result::Ok(c) => ::core::result::Result::Ok(::capnp::capability::FromClientHook::new(c)), ::core::result::Result::Err(e) => ::core::result::Result::Err(e)}
}
}
pub struct Builder<'a> { builder: ::capnp::private::layout::StructBuilder<'a> }
@ -123,6 +127,14 @@ pub mod user_system {
pub fn set_manage(&mut self, value: crate::schema::usersystem_capnp::user_system::manage::Client) {
self.builder.get_pointer_field(1).set_capability(value.client.hook);
}
#[inline]
pub fn get_search(self) -> ::capnp::Result<crate::schema::usersystem_capnp::user_system::search::Client> {
match self.builder.get_pointer_field(2).get_capability() { ::core::result::Result::Ok(c) => ::core::result::Result::Ok(::capnp::capability::FromClientHook::new(c)), ::core::result::Result::Err(e) => ::core::result::Result::Err(e)}
}
#[inline]
pub fn set_search(&mut self, value: crate::schema::usersystem_capnp::user_system::search::Client) {
self.builder.get_pointer_field(2).set_capability(value.client.hook);
}
}
pub struct Pipeline { _typeless: ::capnp::any_pointer::Pipeline }
@ -138,10 +150,13 @@ pub mod user_system {
pub fn get_manage(&self) -> crate::schema::usersystem_capnp::user_system::manage::Client {
::capnp::capability::FromClientHook::new(self._typeless.get_pointer_field(1).as_cap())
}
pub fn get_search(&self) -> crate::schema::usersystem_capnp::user_system::search::Client {
::capnp::capability::FromClientHook::new(self._typeless.get_pointer_field(2).as_cap())
}
}
mod _private {
use capnp::private::layout;
pub const STRUCT_SIZE: layout::StructSize = layout::StructSize { data: 0, pointers: 2 };
pub const STRUCT_SIZE: layout::StructSize = layout::StructSize { data: 0, pointers: 3 };
pub const TYPE_ID: u64 = 0xdabf_c8b5_9d3c_0019;
}
@ -351,6 +366,233 @@ pub mod user_system {
}
pub mod search {
#![allow(unused_variables)]
pub type GetUserByNameParams<> = ::capnp::capability::Params<crate::schema::usersystem_capnp::user_system::search::get_user_by_name_params::Owned>;
pub type GetUserByNameResults<> = ::capnp::capability::Results<crate::schema::general_capnp::optional::Owned<crate::schema::user_capnp::user::Owned>>;
pub struct Client {
pub client: ::capnp::capability::Client,
}
impl ::capnp::capability::FromClientHook for Client {
fn new(hook: Box<dyn (::capnp::private::capability::ClientHook)>) -> Client {
Client { client: ::capnp::capability::Client::new(hook), }
}
}
#[derive(Copy, Clone)]
pub struct Owned(());
impl <'a> ::capnp::traits::Owned<'a> for Owned { type Reader = Client; type Builder = Client; }
impl ::capnp::traits::Pipelined for Owned { type Pipeline = Client; }
impl <'a,> ::capnp::traits::FromPointerReader<'a> for Client<> {
fn get_from_pointer(reader: &::capnp::private::layout::PointerReader<'a>, _default: ::core::option::Option<&'a [capnp::Word]>) -> ::capnp::Result<Client<>> {
::core::result::Result::Ok(::capnp::capability::FromClientHook::new(reader.get_capability()?))
}
}
impl <'a,> ::capnp::traits::FromPointerBuilder<'a> for Client<> {
fn init_pointer(_builder: ::capnp::private::layout::PointerBuilder<'a>, _size: u32) -> Client<> {
unimplemented!()
}
fn get_from_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>, _default: ::core::option::Option<&'a [capnp::Word]>) -> ::capnp::Result<Client<>> {
::core::result::Result::Ok(::capnp::capability::FromClientHook::new(builder.get_capability()?))
}
}
impl <> ::capnp::traits::SetPointerBuilder for Client<> {
fn set_pointer_builder(pointer: ::capnp::private::layout::PointerBuilder<'_>, from: Client<>, _canonicalize: bool) -> ::capnp::Result<()> {
pointer.set_capability(from.client.hook);
::core::result::Result::Ok(())
}
}
impl ::capnp::traits::HasTypeId for Client {
#[inline]
fn type_id() -> u64 { _private::TYPE_ID }
}
impl Clone for Client {
fn clone(&self) -> Client {
Client { client: ::capnp::capability::Client::new(self.client.hook.add_ref()), }
}
}
impl Client {
pub fn get_user_by_name_request(&self) -> ::capnp::capability::Request<crate::schema::usersystem_capnp::user_system::search::get_user_by_name_params::Owned,crate::schema::general_capnp::optional::Owned<crate::schema::user_capnp::user::Owned>> {
self.client.new_call(_private::TYPE_ID, 0, None)
}
}
pub trait Server<> {
fn get_user_by_name(&mut self, _: GetUserByNameParams<>, _: GetUserByNameResults<>) -> ::capnp::capability::Promise<(), ::capnp::Error> { ::capnp::capability::Promise::err(::capnp::Error::unimplemented("method not implemented".to_string())) }
}
pub struct ServerDispatch<_T,> {
pub server: _T,
}
impl <_S: Server + 'static, > ::capnp::capability::FromServer<_S> for Client {
type Dispatch = ServerDispatch<_S, >;
fn from_server(s: _S) -> ServerDispatch<_S, > {
ServerDispatch { server: s, }
}
}
impl <_T: Server> ::core::ops::Deref for ServerDispatch<_T> {
type Target = _T;
fn deref(&self) -> &_T { &self.server}
}
impl <_T: Server> ::core::ops::DerefMut for ServerDispatch<_T> {
fn deref_mut(&mut self) -> &mut _T { &mut self.server}
}
impl <_T: Server> ::capnp::capability::Server for ServerDispatch<_T> {
fn dispatch_call(&mut self, interface_id: u64, method_id: u16, params: ::capnp::capability::Params<::capnp::any_pointer::Owned>, results: ::capnp::capability::Results<::capnp::any_pointer::Owned>) -> ::capnp::capability::Promise<(), ::capnp::Error> {
match interface_id {
_private::TYPE_ID => ServerDispatch::<_T, >::dispatch_call_internal(&mut self.server, method_id, params, results),
_ => { ::capnp::capability::Promise::err(::capnp::Error::unimplemented("Method not implemented.".to_string())) }
}
}
}
impl <_T :Server> ServerDispatch<_T> {
pub fn dispatch_call_internal(server: &mut _T, method_id: u16, params: ::capnp::capability::Params<::capnp::any_pointer::Owned>, results: ::capnp::capability::Results<::capnp::any_pointer::Owned>) -> ::capnp::capability::Promise<(), ::capnp::Error> {
match method_id {
0 => server.get_user_by_name(::capnp::private::capability::internal_get_typed_params(params), ::capnp::private::capability::internal_get_typed_results(results)),
_ => { ::capnp::capability::Promise::err(::capnp::Error::unimplemented("Method not implemented.".to_string())) }
}
}
}
pub mod _private {
pub const TYPE_ID: u64 = 0x9d17_e40c_2f40_05fd;
}
pub mod get_user_by_name_params {
#[derive(Copy, Clone)]
pub struct Owned(());
impl <'a> ::capnp::traits::Owned<'a> for Owned { type Reader = Reader<'a>; type Builder = Builder<'a>; }
impl <'a> ::capnp::traits::OwnedStruct<'a> for Owned { type Reader = Reader<'a>; type Builder = Builder<'a>; }
impl ::capnp::traits::Pipelined for Owned { type Pipeline = Pipeline; }
#[derive(Clone, Copy)]
pub struct Reader<'a> { reader: ::capnp::private::layout::StructReader<'a> }
impl <'a,> ::capnp::traits::HasTypeId for Reader<'a,> {
#[inline]
fn type_id() -> u64 { _private::TYPE_ID }
}
impl <'a,> ::capnp::traits::FromStructReader<'a> for Reader<'a,> {
fn new(reader: ::capnp::private::layout::StructReader<'a>) -> Reader<'a,> {
Reader { reader, }
}
}
impl <'a,> ::capnp::traits::FromPointerReader<'a> for Reader<'a,> {
fn get_from_pointer(reader: &::capnp::private::layout::PointerReader<'a>, default: ::core::option::Option<&'a [capnp::Word]>) -> ::capnp::Result<Reader<'a,>> {
::core::result::Result::Ok(::capnp::traits::FromStructReader::new(reader.get_struct(default)?))
}
}
impl <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> {
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
self.reader
}
}
impl <'a,> ::capnp::traits::Imbue<'a> for Reader<'a,> {
fn imbue(&mut self, cap_table: &'a ::capnp::private::layout::CapTable) {
self.reader.imbue(::capnp::private::layout::CapTableReader::Plain(cap_table))
}
}
impl <'a,> Reader<'a,> {
pub fn reborrow(&self) -> Reader<'_,> {
Reader { .. *self }
}
pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> {
self.reader.total_size()
}
#[inline]
pub fn get_username(self) -> ::capnp::Result<::capnp::text::Reader<'a>> {
::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(0), ::core::option::Option::None)
}
pub fn has_username(&self) -> bool {
!self.reader.get_pointer_field(0).is_null()
}
}
pub struct Builder<'a> { builder: ::capnp::private::layout::StructBuilder<'a> }
impl <'a,> ::capnp::traits::HasStructSize for Builder<'a,> {
#[inline]
fn struct_size() -> ::capnp::private::layout::StructSize { _private::STRUCT_SIZE }
}
impl <'a,> ::capnp::traits::HasTypeId for Builder<'a,> {
#[inline]
fn type_id() -> u64 { _private::TYPE_ID }
}
impl <'a,> ::capnp::traits::FromStructBuilder<'a> for Builder<'a,> {
fn new(builder: ::capnp::private::layout::StructBuilder<'a>) -> Builder<'a, > {
Builder { builder, }
}
}
impl <'a,> ::capnp::traits::ImbueMut<'a> for Builder<'a,> {
fn imbue_mut(&mut self, cap_table: &'a mut ::capnp::private::layout::CapTable) {
self.builder.imbue(::capnp::private::layout::CapTableBuilder::Plain(cap_table))
}
}
impl <'a,> ::capnp::traits::FromPointerBuilder<'a> for Builder<'a,> {
fn init_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>, _size: u32) -> Builder<'a,> {
::capnp::traits::FromStructBuilder::new(builder.init_struct(_private::STRUCT_SIZE))
}
fn get_from_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>, default: ::core::option::Option<&'a [capnp::Word]>) -> ::capnp::Result<Builder<'a,>> {
::core::result::Result::Ok(::capnp::traits::FromStructBuilder::new(builder.get_struct(_private::STRUCT_SIZE, default)?))
}
}
impl <'a,> ::capnp::traits::SetPointerBuilder for Reader<'a,> {
fn set_pointer_builder<'b>(pointer: ::capnp::private::layout::PointerBuilder<'b>, value: Reader<'a,>, canonicalize: bool) -> ::capnp::Result<()> { pointer.set_struct(&value.reader, canonicalize) }
}
impl <'a,> Builder<'a,> {
pub fn into_reader(self) -> Reader<'a,> {
::capnp::traits::FromStructReader::new(self.builder.into_reader())
}
pub fn reborrow(&mut self) -> Builder<'_,> {
Builder { .. *self }
}
pub fn reborrow_as_reader(&self) -> Reader<'_,> {
::capnp::traits::FromStructReader::new(self.builder.into_reader())
}
pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> {
self.builder.into_reader().total_size()
}
#[inline]
pub fn get_username(self) -> ::capnp::Result<::capnp::text::Builder<'a>> {
::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(0), ::core::option::Option::None)
}
#[inline]
pub fn set_username(&mut self, value: ::capnp::text::Reader<'_>) {
self.builder.get_pointer_field(0).set_text(value);
}
#[inline]
pub fn init_username(self, size: u32) -> ::capnp::text::Builder<'a> {
self.builder.get_pointer_field(0).init_text(size)
}
pub fn has_username(&self) -> bool {
!self.builder.get_pointer_field(0).is_null()
}
}
pub struct Pipeline { _typeless: ::capnp::any_pointer::Pipeline }
impl ::capnp::capability::FromTypelessPipeline for Pipeline {
fn new(typeless: ::capnp::any_pointer::Pipeline) -> Pipeline {
Pipeline { _typeless: typeless, }
}
}
impl Pipeline {
}
mod _private {
use capnp::private::layout;
pub const STRUCT_SIZE: layout::StructSize = layout::StructSize { data: 0, pointers: 1 };
pub const TYPE_ID: u64 = 0xd850_6330_6f45_65ca;
}
}
}
pub mod manage {
#![allow(unused_variables)]
pub type GetUserListParams<> = ::capnp::capability::Params<crate::schema::usersystem_capnp::user_system::manage::get_user_list_params::Owned>;
@ -359,6 +601,8 @@ pub mod user_system {
pub type AddUserResults<> = ::capnp::capability::Results<crate::schema::user_capnp::user::Owned>;
pub type RemoveUserParams<> = ::capnp::capability::Params<crate::schema::usersystem_capnp::user_system::manage::remove_user_params::Owned>;
pub type RemoveUserResults<> = ::capnp::capability::Results<crate::schema::usersystem_capnp::user_system::manage::remove_user_results::Owned>;
pub type AddUserFallibleParams<> = ::capnp::capability::Params<crate::schema::usersystem_capnp::user_system::manage::add_user_fallible_params::Owned>;
pub type AddUserFallibleResults<> = ::capnp::capability::Results<crate::schema::general_capnp::fallible::Owned<crate::schema::user_capnp::user::Owned,crate::schema::usersystem_capnp::user_system::manage::add_user_error::Owned>>;
pub struct Client {
pub client: ::capnp::capability::Client,
@ -411,11 +655,15 @@ pub mod user_system {
pub fn remove_user_request(&self) -> ::capnp::capability::Request<crate::schema::usersystem_capnp::user_system::manage::remove_user_params::Owned,crate::schema::usersystem_capnp::user_system::manage::remove_user_results::Owned> {
self.client.new_call(_private::TYPE_ID, 2, None)
}
pub fn add_user_fallible_request(&self) -> ::capnp::capability::Request<crate::schema::usersystem_capnp::user_system::manage::add_user_fallible_params::Owned,crate::schema::general_capnp::fallible::Owned<crate::schema::user_capnp::user::Owned,crate::schema::usersystem_capnp::user_system::manage::add_user_error::Owned>> {
self.client.new_call(_private::TYPE_ID, 3, None)
}
}
pub trait Server<> {
fn get_user_list(&mut self, _: GetUserListParams<>, _: GetUserListResults<>) -> ::capnp::capability::Promise<(), ::capnp::Error> { ::capnp::capability::Promise::err(::capnp::Error::unimplemented("method not implemented".to_string())) }
fn add_user(&mut self, _: AddUserParams<>, _: AddUserResults<>) -> ::capnp::capability::Promise<(), ::capnp::Error> { ::capnp::capability::Promise::err(::capnp::Error::unimplemented("method not implemented".to_string())) }
fn remove_user(&mut self, _: RemoveUserParams<>, _: RemoveUserResults<>) -> ::capnp::capability::Promise<(), ::capnp::Error> { ::capnp::capability::Promise::err(::capnp::Error::unimplemented("method not implemented".to_string())) }
fn add_user_fallible(&mut self, _: AddUserFallibleParams<>, _: AddUserFallibleResults<>) -> ::capnp::capability::Promise<(), ::capnp::Error> { ::capnp::capability::Promise::err(::capnp::Error::unimplemented("method not implemented".to_string())) }
}
pub struct ServerDispatch<_T,> {
pub server: _T,
@ -447,6 +695,7 @@ pub mod user_system {
0 => server.get_user_list(::capnp::private::capability::internal_get_typed_params(params), ::capnp::private::capability::internal_get_typed_results(results)),
1 => server.add_user(::capnp::private::capability::internal_get_typed_params(params), ::capnp::private::capability::internal_get_typed_results(results)),
2 => server.remove_user(::capnp::private::capability::internal_get_typed_params(params), ::capnp::private::capability::internal_get_typed_results(results)),
3 => server.add_user_fallible(::capnp::private::capability::internal_get_typed_params(params), ::capnp::private::capability::internal_get_typed_results(results)),
_ => { ::capnp::capability::Promise::err(::capnp::Error::unimplemented("Method not implemented.".to_string())) }
}
}
@ -455,6 +704,158 @@ pub mod user_system {
pub const TYPE_ID: u64 = 0x9971_b909_6e1d_868c;
}
pub mod add_user_error {
#[derive(Copy, Clone)]
pub struct Owned(());
impl <'a> ::capnp::traits::Owned<'a> for Owned { type Reader = Reader<'a>; type Builder = Builder<'a>; }
impl <'a> ::capnp::traits::OwnedStruct<'a> for Owned { type Reader = Reader<'a>; type Builder = Builder<'a>; }
impl ::capnp::traits::Pipelined for Owned { type Pipeline = Pipeline; }
#[derive(Clone, Copy)]
pub struct Reader<'a> { reader: ::capnp::private::layout::StructReader<'a> }
impl <'a,> ::capnp::traits::HasTypeId for Reader<'a,> {
#[inline]
fn type_id() -> u64 { _private::TYPE_ID }
}
impl <'a,> ::capnp::traits::FromStructReader<'a> for Reader<'a,> {
fn new(reader: ::capnp::private::layout::StructReader<'a>) -> Reader<'a,> {
Reader { reader, }
}
}
impl <'a,> ::capnp::traits::FromPointerReader<'a> for Reader<'a,> {
fn get_from_pointer(reader: &::capnp::private::layout::PointerReader<'a>, default: ::core::option::Option<&'a [capnp::Word]>) -> ::capnp::Result<Reader<'a,>> {
::core::result::Result::Ok(::capnp::traits::FromStructReader::new(reader.get_struct(default)?))
}
}
impl <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> {
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
self.reader
}
}
impl <'a,> ::capnp::traits::Imbue<'a> for Reader<'a,> {
fn imbue(&mut self, cap_table: &'a ::capnp::private::layout::CapTable) {
self.reader.imbue(::capnp::private::layout::CapTableReader::Plain(cap_table))
}
}
impl <'a,> Reader<'a,> {
pub fn reborrow(&self) -> Reader<'_,> {
Reader { .. *self }
}
pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> {
self.reader.total_size()
}
#[inline]
pub fn get_error(self) -> ::core::result::Result<crate::schema::usersystem_capnp::user_system::manage::add_user_error::AddUserError,::capnp::NotInSchema> {
::capnp::traits::FromU16::from_u16(self.reader.get_data_field::<u16>(0))
}
}
pub struct Builder<'a> { builder: ::capnp::private::layout::StructBuilder<'a> }
impl <'a,> ::capnp::traits::HasStructSize for Builder<'a,> {
#[inline]
fn struct_size() -> ::capnp::private::layout::StructSize { _private::STRUCT_SIZE }
}
impl <'a,> ::capnp::traits::HasTypeId for Builder<'a,> {
#[inline]
fn type_id() -> u64 { _private::TYPE_ID }
}
impl <'a,> ::capnp::traits::FromStructBuilder<'a> for Builder<'a,> {
fn new(builder: ::capnp::private::layout::StructBuilder<'a>) -> Builder<'a, > {
Builder { builder, }
}
}
impl <'a,> ::capnp::traits::ImbueMut<'a> for Builder<'a,> {
fn imbue_mut(&mut self, cap_table: &'a mut ::capnp::private::layout::CapTable) {
self.builder.imbue(::capnp::private::layout::CapTableBuilder::Plain(cap_table))
}
}
impl <'a,> ::capnp::traits::FromPointerBuilder<'a> for Builder<'a,> {
fn init_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>, _size: u32) -> Builder<'a,> {
::capnp::traits::FromStructBuilder::new(builder.init_struct(_private::STRUCT_SIZE))
}
fn get_from_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>, default: ::core::option::Option<&'a [capnp::Word]>) -> ::capnp::Result<Builder<'a,>> {
::core::result::Result::Ok(::capnp::traits::FromStructBuilder::new(builder.get_struct(_private::STRUCT_SIZE, default)?))
}
}
impl <'a,> ::capnp::traits::SetPointerBuilder for Reader<'a,> {
fn set_pointer_builder<'b>(pointer: ::capnp::private::layout::PointerBuilder<'b>, value: Reader<'a,>, canonicalize: bool) -> ::capnp::Result<()> { pointer.set_struct(&value.reader, canonicalize) }
}
impl <'a,> Builder<'a,> {
pub fn into_reader(self) -> Reader<'a,> {
::capnp::traits::FromStructReader::new(self.builder.into_reader())
}
pub fn reborrow(&mut self) -> Builder<'_,> {
Builder { .. *self }
}
pub fn reborrow_as_reader(&self) -> Reader<'_,> {
::capnp::traits::FromStructReader::new(self.builder.into_reader())
}
pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> {
self.builder.into_reader().total_size()
}
#[inline]
pub fn get_error(self) -> ::core::result::Result<crate::schema::usersystem_capnp::user_system::manage::add_user_error::AddUserError,::capnp::NotInSchema> {
::capnp::traits::FromU16::from_u16(self.builder.get_data_field::<u16>(0))
}
#[inline]
pub fn set_error(&mut self, value: crate::schema::usersystem_capnp::user_system::manage::add_user_error::AddUserError) {
self.builder.set_data_field::<u16>(0, value as u16)
}
}
pub struct Pipeline { _typeless: ::capnp::any_pointer::Pipeline }
impl ::capnp::capability::FromTypelessPipeline for Pipeline {
fn new(typeless: ::capnp::any_pointer::Pipeline) -> Pipeline {
Pipeline { _typeless: typeless, }
}
}
impl Pipeline {
}
mod _private {
use capnp::private::layout;
pub const STRUCT_SIZE: layout::StructSize = layout::StructSize { data: 1, pointers: 0 };
pub const TYPE_ID: u64 = 0xf892_55fa_c5eb_df90;
}
#[repr(u16)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum AddUserError {
AlreadyExists = 0,
UsernameInvalid = 1,
PasswordInvalid = 2,
}
impl ::capnp::traits::FromU16 for AddUserError {
#[inline]
fn from_u16(value: u16) -> ::core::result::Result<AddUserError, ::capnp::NotInSchema> {
match value {
0 => ::core::result::Result::Ok(AddUserError::AlreadyExists),
1 => ::core::result::Result::Ok(AddUserError::UsernameInvalid),
2 => ::core::result::Result::Ok(AddUserError::PasswordInvalid),
n => ::core::result::Result::Err(::capnp::NotInSchema(n)),
}
}
}
impl ::capnp::traits::ToU16 for AddUserError {
#[inline]
fn to_u16(self) -> u16 { self as u16 }
}
impl ::capnp::traits::HasTypeId for AddUserError {
#[inline]
fn type_id() -> u64 { 0x9623_12d4_e9d7_4876u64 }
}
}
pub mod get_user_list_params {
#[derive(Copy, Clone)]
pub struct Owned(());
@ -1110,5 +1511,162 @@ pub mod user_system {
pub const TYPE_ID: u64 = 0xdfb7_a55c_6d34_06be;
}
}
pub mod add_user_fallible_params {
#[derive(Copy, Clone)]
pub struct Owned(());
impl <'a> ::capnp::traits::Owned<'a> for Owned { type Reader = Reader<'a>; type Builder = Builder<'a>; }
impl <'a> ::capnp::traits::OwnedStruct<'a> for Owned { type Reader = Reader<'a>; type Builder = Builder<'a>; }
impl ::capnp::traits::Pipelined for Owned { type Pipeline = Pipeline; }
#[derive(Clone, Copy)]
pub struct Reader<'a> { reader: ::capnp::private::layout::StructReader<'a> }
impl <'a,> ::capnp::traits::HasTypeId for Reader<'a,> {
#[inline]
fn type_id() -> u64 { _private::TYPE_ID }
}
impl <'a,> ::capnp::traits::FromStructReader<'a> for Reader<'a,> {
fn new(reader: ::capnp::private::layout::StructReader<'a>) -> Reader<'a,> {
Reader { reader, }
}
}
impl <'a,> ::capnp::traits::FromPointerReader<'a> for Reader<'a,> {
fn get_from_pointer(reader: &::capnp::private::layout::PointerReader<'a>, default: ::core::option::Option<&'a [capnp::Word]>) -> ::capnp::Result<Reader<'a,>> {
::core::result::Result::Ok(::capnp::traits::FromStructReader::new(reader.get_struct(default)?))
}
}
impl <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> {
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
self.reader
}
}
impl <'a,> ::capnp::traits::Imbue<'a> for Reader<'a,> {
fn imbue(&mut self, cap_table: &'a ::capnp::private::layout::CapTable) {
self.reader.imbue(::capnp::private::layout::CapTableReader::Plain(cap_table))
}
}
impl <'a,> Reader<'a,> {
pub fn reborrow(&self) -> Reader<'_,> {
Reader { .. *self }
}
pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> {
self.reader.total_size()
}
#[inline]
pub fn get_username(self) -> ::capnp::Result<::capnp::text::Reader<'a>> {
::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(0), ::core::option::Option::None)
}
pub fn has_username(&self) -> bool {
!self.reader.get_pointer_field(0).is_null()
}
#[inline]
pub fn get_password(self) -> ::capnp::Result<::capnp::text::Reader<'a>> {
::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(1), ::core::option::Option::None)
}
pub fn has_password(&self) -> bool {
!self.reader.get_pointer_field(1).is_null()
}
}
pub struct Builder<'a> { builder: ::capnp::private::layout::StructBuilder<'a> }
impl <'a,> ::capnp::traits::HasStructSize for Builder<'a,> {
#[inline]
fn struct_size() -> ::capnp::private::layout::StructSize { _private::STRUCT_SIZE }
}
impl <'a,> ::capnp::traits::HasTypeId for Builder<'a,> {
#[inline]
fn type_id() -> u64 { _private::TYPE_ID }
}
impl <'a,> ::capnp::traits::FromStructBuilder<'a> for Builder<'a,> {
fn new(builder: ::capnp::private::layout::StructBuilder<'a>) -> Builder<'a, > {
Builder { builder, }
}
}
impl <'a,> ::capnp::traits::ImbueMut<'a> for Builder<'a,> {
fn imbue_mut(&mut self, cap_table: &'a mut ::capnp::private::layout::CapTable) {
self.builder.imbue(::capnp::private::layout::CapTableBuilder::Plain(cap_table))
}
}
impl <'a,> ::capnp::traits::FromPointerBuilder<'a> for Builder<'a,> {
fn init_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>, _size: u32) -> Builder<'a,> {
::capnp::traits::FromStructBuilder::new(builder.init_struct(_private::STRUCT_SIZE))
}
fn get_from_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>, default: ::core::option::Option<&'a [capnp::Word]>) -> ::capnp::Result<Builder<'a,>> {
::core::result::Result::Ok(::capnp::traits::FromStructBuilder::new(builder.get_struct(_private::STRUCT_SIZE, default)?))
}
}
impl <'a,> ::capnp::traits::SetPointerBuilder for Reader<'a,> {
fn set_pointer_builder<'b>(pointer: ::capnp::private::layout::PointerBuilder<'b>, value: Reader<'a,>, canonicalize: bool) -> ::capnp::Result<()> { pointer.set_struct(&value.reader, canonicalize) }
}
impl <'a,> Builder<'a,> {
pub fn into_reader(self) -> Reader<'a,> {
::capnp::traits::FromStructReader::new(self.builder.into_reader())
}
pub fn reborrow(&mut self) -> Builder<'_,> {
Builder { .. *self }
}
pub fn reborrow_as_reader(&self) -> Reader<'_,> {
::capnp::traits::FromStructReader::new(self.builder.into_reader())
}
pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> {
self.builder.into_reader().total_size()
}
#[inline]
pub fn get_username(self) -> ::capnp::Result<::capnp::text::Builder<'a>> {
::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(0), ::core::option::Option::None)
}
#[inline]
pub fn set_username(&mut self, value: ::capnp::text::Reader<'_>) {
self.builder.get_pointer_field(0).set_text(value);
}
#[inline]
pub fn init_username(self, size: u32) -> ::capnp::text::Builder<'a> {
self.builder.get_pointer_field(0).init_text(size)
}
pub fn has_username(&self) -> bool {
!self.builder.get_pointer_field(0).is_null()
}
#[inline]
pub fn get_password(self) -> ::capnp::Result<::capnp::text::Builder<'a>> {
::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(1), ::core::option::Option::None)
}
#[inline]
pub fn set_password(&mut self, value: ::capnp::text::Reader<'_>) {
self.builder.get_pointer_field(1).set_text(value);
}
#[inline]
pub fn init_password(self, size: u32) -> ::capnp::text::Builder<'a> {
self.builder.get_pointer_field(1).init_text(size)
}
pub fn has_password(&self) -> bool {
!self.builder.get_pointer_field(1).is_null()
}
}
pub struct Pipeline { _typeless: ::capnp::any_pointer::Pipeline }
impl ::capnp::capability::FromTypelessPipeline for Pipeline {
fn new(typeless: ::capnp::any_pointer::Pipeline) -> Pipeline {
Pipeline { _typeless: typeless, }
}
}
impl Pipeline {
}
mod _private {
use capnp::private::layout;
pub const STRUCT_SIZE: layout::StructSize = layout::StructSize { data: 0, pointers: 2 };
pub const TYPE_ID: u64 = 0xf5bf_a6eb_aa16_f44c;
}
}
}
}

View File

@ -1,18 +1,15 @@
use crate::capnp::user::User;
use crate::resources::modules::fabaccess::{ArchivedStatus, Status};
use crate::resources::Resource;
use crate::session::SessionHandle;
use api::machine_capnp::machine::{
self,
admin, admin::Server as AdminServer, check, check::Server as CheckServer, in_use as inuse,
in_use::Server as InUseServer, info, info::Server as InfoServer, manage,
manage::Server as ManageServer, use_, use_::Server as UseServer,
MachineState,
};
use api::general_capnp::optional;
use api::machine_capnp::machine::{
self, admin, admin::Server as AdminServer, check, check::Server as CheckServer,
in_use as inuse, in_use::Server as InUseServer, info, info::Server as InfoServer, manage,
manage::Server as ManageServer, use_, use_::Server as UseServer, MachineState,
};
use capnp::capability::Promise;
use capnp_rpc::pry;
use crate::capnp::user::User;
#[derive(Clone)]
pub struct Machine {
@ -37,18 +34,23 @@ impl Machine {
if let Some(ref category) = self.resource.get_description().category {
builder.set_category(category);
}
builder.set_urn(&format!("urn:fabaccess:resource:{}", self.resource.get_id()));
builder.set_urn(&format!(
"urn:fabaccess:resource:{}",
self.resource.get_id()
));
{
let user = self.session.get_user_ref();
let state = self.resource.get_state_ref();
let state = state.as_ref();
if self.session.has_write(&self.resource) && match &state.inner.state {
ArchivedStatus::Free => true,
ArchivedStatus::Reserved(reserver) if reserver == &user => true,
_ => false,
} {
if self.session.has_write(&self.resource)
&& match &state.inner.state {
ArchivedStatus::Free => true,
ArchivedStatus::Reserved(reserver) if reserver == &user => true,
_ => false,
}
{
builder.set_use(capnp_rpc::new_client(self.clone()));
}
@ -67,7 +69,7 @@ impl Machine {
builder.set_inuse(capnp_rpc::new_client(self.clone()));
}
MachineState::InUse
},
}
ArchivedStatus::Reserved(_) => MachineState::Reserved,
ArchivedStatus::ToCheck(_) => MachineState::ToCheck,
};
@ -85,7 +87,11 @@ impl Machine {
this.build_into(builder)
}
pub fn optional_build(session: SessionHandle, resource: Resource, builder: optional::Builder<machine::Owned>) {
pub fn optional_build(
session: SessionHandle,
resource: Resource,
builder: optional::Builder<machine::Owned>,
) {
let this = Self::new(session.clone(), resource.clone());
if this.resource.visible(&session) || session.has_read(&resource) {
let builder = builder.init_just();
@ -135,9 +141,7 @@ impl UseServer for Machine {
let session = self.session.clone();
Promise::from_future(async move {
let user = session.get_user_ref();
resource
.try_update(session, Status::Reserved(user))
.await;
resource.try_update(session, Status::Reserved(user)).await;
Ok(())
})
}
@ -208,8 +212,16 @@ impl ManageServer for Machine {
) -> Promise<(), ::capnp::Error> {
let mut builder = result.get();
let user = User::new_self(self.session.clone());
user.build_optional(self.resource.get_current_user(), builder.reborrow().init_current_user());
user.build_optional(self.resource.get_previous_user(), builder.init_last_user());
User::build_optional(
&self.session,
self.resource.get_current_user(),
builder.reborrow().init_current_user(),
);
User::build_optional(
&self.session,
self.resource.get_previous_user(),
builder.init_last_user(),
);
Promise::ok(())
}
fn set_property(
@ -310,9 +322,11 @@ impl AdminServer for Machine {
APIMState::InUse => Status::InUse(user),
APIMState::Reserved => Status::Reserved(user),
APIMState::ToCheck => Status::ToCheck(user),
APIMState::Totakeover => return Promise::err(::capnp::Error::unimplemented(
APIMState::Totakeover => {
return Promise::err(::capnp::Error::unimplemented(
"totakeover not implemented".to_string(),
)),
))
}
};
let resource = self.resource.clone();
Promise::from_future(async move {

View File

@ -22,10 +22,10 @@ impl User {
Self::new(session, user)
}
pub fn build_optional(&self, user: Option<UserRef>, builder: optional::Builder<user::Owned>) {
if let Some(user) = user.and_then(|u| self.session.users.get_user(u.get_username())) {
pub fn build_optional(session: &SessionHandle, user: Option<UserRef>, builder: optional::Builder<user::Owned>) {
if let Some(user) = user.and_then(|u| session.users.get_user(u.get_username())) {
let builder = builder.init_just();
Self::fill(&self.session, user, builder);
Self::fill(&session, user, builder);
}
}

View File

@ -1,13 +1,13 @@
use capnp::capability::Promise;
use capnp_rpc::pry;
use api::usersystem_capnp::user_system::{
info, manage,
info, manage, search
};
use crate::capnp::user::User;
use crate::session::SessionHandle;
use crate::users::db;
use crate::users::{db, UserRef};
#[derive(Clone)]
@ -93,3 +93,16 @@ impl manage::Server for Users {
Promise::ok(())
}
}
impl search::Server for Users {
fn get_user_by_name(
&mut self,
params: search::GetUserByNameParams,
mut result: search::GetUserByNameResults,
) -> Promise<(), ::capnp::Error> {
let username: &str = pry!(pry!(params.get()).get_username());
let userref = UserRef::new(username.to_string());
User::build_optional(&self.session, Some(userref), result.get());
Promise::ok(())
}
}