This commit is contained in:
Nadja Reitzenstein 2022-04-21 23:02:58 +02:00
parent 5538dd6751
commit 15c878e1d2
12 changed files with 831 additions and 2176 deletions

@ -1 +1 @@
Subproject commit c9283ebd696ed6dd428a7c3d24820889f7ab4bf3
Subproject commit 2406e77fb9fd2ce3d6e183742521a5d9c9cf77af

View File

@ -1209,16 +1209,25 @@ pub mod session {
self.reader.total_size()
}
#[inline]
pub fn get_machine_system(self) -> ::capnp::Result<crate::schema::machinesystem_capnp::machine_system::Client> {
match self.reader.get_pointer_field(0).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 fn get_machine_system(self) -> ::capnp::Result<crate::schema::machinesystem_capnp::machine_system::Reader<'a>> {
::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(0), ::core::option::Option::None)
}
pub fn has_machine_system(&self) -> bool {
!self.reader.get_pointer_field(0).is_null()
}
#[inline]
pub fn get_user_system(self) -> ::capnp::Result<crate::schema::usersystem_capnp::user_system::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)}
pub fn get_user_system(self) -> ::capnp::Result<crate::schema::usersystem_capnp::user_system::Reader<'a>> {
::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(1), ::core::option::Option::None)
}
pub fn has_user_system(&self) -> bool {
!self.reader.get_pointer_field(1).is_null()
}
#[inline]
pub fn get_permission_system(self) -> ::capnp::Result<crate::schema::permissionsystem_capnp::permission_system::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 fn get_permission_system(self) -> ::capnp::Result<crate::schema::permissionsystem_capnp::permission_system::Reader<'a>> {
::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(2), ::core::option::Option::None)
}
pub fn has_permission_system(&self) -> bool {
!self.reader.get_pointer_field(2).is_null()
}
}
@ -1271,28 +1280,49 @@ pub mod session {
self.builder.into_reader().total_size()
}
#[inline]
pub fn get_machine_system(self) -> ::capnp::Result<crate::schema::machinesystem_capnp::machine_system::Client> {
match self.builder.get_pointer_field(0).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 fn get_machine_system(self) -> ::capnp::Result<crate::schema::machinesystem_capnp::machine_system::Builder<'a>> {
::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(0), ::core::option::Option::None)
}
#[inline]
pub fn set_machine_system(&mut self, value: crate::schema::machinesystem_capnp::machine_system::Client) {
self.builder.get_pointer_field(0).set_capability(value.client.hook);
pub fn set_machine_system(&mut self, value: crate::schema::machinesystem_capnp::machine_system::Reader<'_>) -> ::capnp::Result<()> {
::capnp::traits::SetPointerBuilder::set_pointer_builder(self.builder.get_pointer_field(0), value, false)
}
#[inline]
pub fn get_user_system(self) -> ::capnp::Result<crate::schema::usersystem_capnp::user_system::Client> {
match self.builder.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)}
pub fn init_machine_system(self, ) -> crate::schema::machinesystem_capnp::machine_system::Builder<'a> {
::capnp::traits::FromPointerBuilder::init_pointer(self.builder.get_pointer_field(0), 0)
}
pub fn has_machine_system(&self) -> bool {
!self.builder.get_pointer_field(0).is_null()
}
#[inline]
pub fn set_user_system(&mut self, value: crate::schema::usersystem_capnp::user_system::Client) {
self.builder.get_pointer_field(1).set_capability(value.client.hook);
pub fn get_user_system(self) -> ::capnp::Result<crate::schema::usersystem_capnp::user_system::Builder<'a>> {
::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(1), ::core::option::Option::None)
}
#[inline]
pub fn get_permission_system(self) -> ::capnp::Result<crate::schema::permissionsystem_capnp::permission_system::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)}
pub fn set_user_system(&mut self, value: crate::schema::usersystem_capnp::user_system::Reader<'_>) -> ::capnp::Result<()> {
::capnp::traits::SetPointerBuilder::set_pointer_builder(self.builder.get_pointer_field(1), value, false)
}
#[inline]
pub fn set_permission_system(&mut self, value: crate::schema::permissionsystem_capnp::permission_system::Client) {
self.builder.get_pointer_field(2).set_capability(value.client.hook);
pub fn init_user_system(self, ) -> crate::schema::usersystem_capnp::user_system::Builder<'a> {
::capnp::traits::FromPointerBuilder::init_pointer(self.builder.get_pointer_field(1), 0)
}
pub fn has_user_system(&self) -> bool {
!self.builder.get_pointer_field(1).is_null()
}
#[inline]
pub fn get_permission_system(self) -> ::capnp::Result<crate::schema::permissionsystem_capnp::permission_system::Builder<'a>> {
::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(2), ::core::option::Option::None)
}
#[inline]
pub fn set_permission_system(&mut self, value: crate::schema::permissionsystem_capnp::permission_system::Reader<'_>) -> ::capnp::Result<()> {
::capnp::traits::SetPointerBuilder::set_pointer_builder(self.builder.get_pointer_field(2), value, false)
}
#[inline]
pub fn init_permission_system(self, ) -> crate::schema::permissionsystem_capnp::permission_system::Builder<'a> {
::capnp::traits::FromPointerBuilder::init_pointer(self.builder.get_pointer_field(2), 0)
}
pub fn has_permission_system(&self) -> bool {
!self.builder.get_pointer_field(2).is_null()
}
}
@ -1303,14 +1333,14 @@ pub mod session {
}
}
impl Pipeline {
pub fn get_machine_system(&self) -> crate::schema::machinesystem_capnp::machine_system::Client {
::capnp::capability::FromClientHook::new(self._typeless.get_pointer_field(0).as_cap())
pub fn get_machine_system(&self) -> crate::schema::machinesystem_capnp::machine_system::Pipeline {
::capnp::capability::FromTypelessPipeline::new(self._typeless.get_pointer_field(0))
}
pub fn get_user_system(&self) -> crate::schema::usersystem_capnp::user_system::Client {
::capnp::capability::FromClientHook::new(self._typeless.get_pointer_field(1).as_cap())
pub fn get_user_system(&self) -> crate::schema::usersystem_capnp::user_system::Pipeline {
::capnp::capability::FromTypelessPipeline::new(self._typeless.get_pointer_field(1))
}
pub fn get_permission_system(&self) -> crate::schema::permissionsystem_capnp::permission_system::Client {
::capnp::capability::FromClientHook::new(self._typeless.get_pointer_field(2).as_cap())
pub fn get_permission_system(&self) -> crate::schema::permissionsystem_capnp::permission_system::Pipeline {
::capnp::capability::FromTypelessPipeline::new(self._typeless.get_pointer_field(2))
}
}
mod _private {

View File

@ -3,94 +3,130 @@
// source: machinesystem.capnp
pub mod machine_system {
#![allow(unused_variables)]
pub type InfoParams<> = ::capnp::capability::Params<crate::schema::machinesystem_capnp::machine_system::info_params::Owned>;
pub type InfoResults<> = ::capnp::capability::Results<crate::schema::machinesystem_capnp::machine_system::info_results::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 <'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; }
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 {
#[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 Clone for Client {
fn clone(&self) -> Client {
Client { client: ::capnp::capability::Client::new(self.client.hook.add_ref()), }
impl <'a,> ::capnp::traits::FromStructReader<'a> for Reader<'a,> {
fn new(reader: ::capnp::private::layout::StructReader<'a>) -> Reader<'a,> {
Reader { reader, }
}
}
impl Client {
pub fn info_request(&self) -> ::capnp::capability::Request<crate::schema::machinesystem_capnp::machine_system::info_params::Owned,crate::schema::machinesystem_capnp::machine_system::info_results::Owned> {
self.client.new_call(_private::TYPE_ID, 0, None)
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)?))
}
}
pub trait Server<> {
fn info(&mut self, _: InfoParams<>, _: InfoResults<>) -> ::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 <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> {
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
self.reader
}
}
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 <'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 <_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.info(::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())) }
}
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_info(self) -> ::capnp::Result<crate::schema::machinesystem_capnp::machine_system::info::Client> {
match self.reader.get_pointer_field(0).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 mod _private {
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_info(self) -> ::capnp::Result<crate::schema::machinesystem_capnp::machine_system::info::Client> {
match self.builder.get_pointer_field(0).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_info(&mut self, value: crate::schema::machinesystem_capnp::machine_system::info::Client) {
self.builder.get_pointer_field(0).set_capability(value.client.hook);
}
}
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 {
pub fn get_info(&self) -> crate::schema::machinesystem_capnp::machine_system::info::Client {
::capnp::capability::FromClientHook::new(self._typeless.get_pointer_field(0).as_cap())
}
}
mod _private {
use capnp::private::layout;
pub const STRUCT_SIZE: layout::StructSize = layout::StructSize { data: 0, pointers: 1 };
pub const TYPE_ID: u64 = 0x8771_90c7_e487_ddb6;
}
@ -717,245 +753,4 @@ pub mod machine_system {
}
}
}
pub mod info_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()
}
}
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()
}
}
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: 0 };
pub const TYPE_ID: u64 = 0xe531_7e00_9ffa_0a21;
}
}
pub mod info_results {
#[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_info(self) -> ::capnp::Result<crate::schema::machinesystem_capnp::machine_system::info::Client> {
match self.reader.get_pointer_field(0).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> }
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_info(self) -> ::capnp::Result<crate::schema::machinesystem_capnp::machine_system::info::Client> {
match self.builder.get_pointer_field(0).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_info(&mut self, value: crate::schema::machinesystem_capnp::machine_system::info::Client) {
self.builder.get_pointer_field(0).set_capability(value.client.hook);
}
}
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 {
pub fn get_info(&self) -> crate::schema::machinesystem_capnp::machine_system::info::Client {
::capnp::capability::FromClientHook::new(self._typeless.get_pointer_field(0).as_cap())
}
}
mod _private {
use capnp::private::layout;
pub const STRUCT_SIZE: layout::StructSize = layout::StructSize { data: 0, pointers: 1 };
pub const TYPE_ID: u64 = 0xd675_edfa_cb72_2594;
}
}
}

View File

@ -3,101 +3,145 @@
// source: permissionsystem.capnp
pub mod permission_system {
#![allow(unused_variables)]
pub type InfoParams<> = ::capnp::capability::Params<crate::schema::permissionsystem_capnp::permission_system::info_params::Owned>;
pub type InfoResults<> = ::capnp::capability::Results<crate::schema::permissionsystem_capnp::permission_system::info_results::Owned>;
pub type ManageParams<> = ::capnp::capability::Params<crate::schema::permissionsystem_capnp::permission_system::manage_params::Owned>;
pub type ManageResults<> = ::capnp::capability::Results<crate::schema::permissionsystem_capnp::permission_system::manage_results::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 <'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; }
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 {
#[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 Clone for Client {
fn clone(&self) -> Client {
Client { client: ::capnp::capability::Client::new(self.client.hook.add_ref()), }
impl <'a,> ::capnp::traits::FromStructReader<'a> for Reader<'a,> {
fn new(reader: ::capnp::private::layout::StructReader<'a>) -> Reader<'a,> {
Reader { reader, }
}
}
impl Client {
pub fn info_request(&self) -> ::capnp::capability::Request<crate::schema::permissionsystem_capnp::permission_system::info_params::Owned,crate::schema::permissionsystem_capnp::permission_system::info_results::Owned> {
self.client.new_call(_private::TYPE_ID, 0, None)
}
pub fn manage_request(&self) -> ::capnp::capability::Request<crate::schema::permissionsystem_capnp::permission_system::manage_params::Owned,crate::schema::permissionsystem_capnp::permission_system::manage_results::Owned> {
self.client.new_call(_private::TYPE_ID, 1, None)
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)?))
}
}
pub trait Server<> {
fn info(&mut self, _: InfoParams<>, _: InfoResults<>) -> ::capnp::capability::Promise<(), ::capnp::Error> { ::capnp::capability::Promise::err(::capnp::Error::unimplemented("method not implemented".to_string())) }
fn manage(&mut self, _: ManageParams<>, _: ManageResults<>) -> ::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 <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> {
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
self.reader
}
}
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 <'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 <_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.info(::capnp::private::capability::internal_get_typed_params(params), ::capnp::private::capability::internal_get_typed_results(results)),
1 => server.manage(::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())) }
}
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_info(self) -> ::capnp::Result<crate::schema::permissionsystem_capnp::permission_system::info::Client> {
match self.reader.get_pointer_field(0).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_manage(self) -> ::capnp::Result<crate::schema::permissionsystem_capnp::permission_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)}
}
}
pub mod _private {
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_info(self) -> ::capnp::Result<crate::schema::permissionsystem_capnp::permission_system::info::Client> {
match self.builder.get_pointer_field(0).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_info(&mut self, value: crate::schema::permissionsystem_capnp::permission_system::info::Client) {
self.builder.get_pointer_field(0).set_capability(value.client.hook);
}
#[inline]
pub fn get_manage(self) -> ::capnp::Result<crate::schema::permissionsystem_capnp::permission_system::manage::Client> {
match self.builder.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 set_manage(&mut self, value: crate::schema::permissionsystem_capnp::permission_system::manage::Client) {
self.builder.get_pointer_field(1).set_capability(value.client.hook);
}
}
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 {
pub fn get_info(&self) -> crate::schema::permissionsystem_capnp::permission_system::info::Client {
::capnp::capability::FromClientHook::new(self._typeless.get_pointer_field(0).as_cap())
}
pub fn get_manage(&self) -> crate::schema::permissionsystem_capnp::permission_system::manage::Client {
::capnp::capability::FromClientHook::new(self._typeless.get_pointer_field(1).as_cap())
}
}
mod _private {
use capnp::private::layout;
pub const STRUCT_SIZE: layout::StructSize = layout::StructSize { data: 0, pointers: 2 };
pub const TYPE_ID: u64 = 0xcafb_f059_d7a0_0c3b;
}
@ -525,486 +569,4 @@ pub mod permission_system {
pub const TYPE_ID: u64 = 0xfd2c_0c85_d50a_57e6;
}
}
pub mod info_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()
}
}
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()
}
}
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: 0 };
pub const TYPE_ID: u64 = 0xe10f_22a8_fd60_fc8a;
}
}
pub mod info_results {
#[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_info(self) -> ::capnp::Result<crate::schema::permissionsystem_capnp::permission_system::info::Client> {
match self.reader.get_pointer_field(0).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> }
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_info(self) -> ::capnp::Result<crate::schema::permissionsystem_capnp::permission_system::info::Client> {
match self.builder.get_pointer_field(0).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_info(&mut self, value: crate::schema::permissionsystem_capnp::permission_system::info::Client) {
self.builder.get_pointer_field(0).set_capability(value.client.hook);
}
}
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 {
pub fn get_info(&self) -> crate::schema::permissionsystem_capnp::permission_system::info::Client {
::capnp::capability::FromClientHook::new(self._typeless.get_pointer_field(0).as_cap())
}
}
mod _private {
use capnp::private::layout;
pub const STRUCT_SIZE: layout::StructSize = layout::StructSize { data: 0, pointers: 1 };
pub const TYPE_ID: u64 = 0xc85c_26ea_dff7_6440;
}
}
pub mod manage_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()
}
}
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()
}
}
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: 0 };
pub const TYPE_ID: u64 = 0x9a88_ca08_11fa_11f0;
}
}
pub mod manage_results {
#[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_manage(self) -> ::capnp::Result<crate::schema::permissionsystem_capnp::permission_system::manage::Client> {
match self.reader.get_pointer_field(0).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> }
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_manage(self) -> ::capnp::Result<crate::schema::permissionsystem_capnp::permission_system::manage::Client> {
match self.builder.get_pointer_field(0).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_manage(&mut self, value: crate::schema::permissionsystem_capnp::permission_system::manage::Client) {
self.builder.get_pointer_field(0).set_capability(value.client.hook);
}
}
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 {
pub fn get_manage(&self) -> crate::schema::permissionsystem_capnp::permission_system::manage::Client {
::capnp::capability::FromClientHook::new(self._typeless.get_pointer_field(0).as_cap())
}
}
mod _private {
use capnp::private::layout;
pub const STRUCT_SIZE: layout::StructSize = layout::StructSize { data: 0, pointers: 1 };
pub const TYPE_ID: u64 = 0xca25_54ce_2a90_861e;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
use crate::session::SessionHandle;
use api::machinesystem_capnp::machine_system::{
info, InfoParams, InfoResults, Server as MachineSystem,
info,
};
use capnp::capability::Promise;
use capnp_rpc::pry;
@ -23,14 +23,6 @@ impl Machines {
}
}
impl MachineSystem for Machines {
fn info(&mut self, _: InfoParams, mut result: InfoResults) -> Promise<(), ::capnp::Error> {
// TODO permission checking
result.get().set_info(capnp_rpc::new_client(self.clone()));
Promise::ok(())
}
}
impl info::Server for Machines {
fn get_machine_list(
&mut self,

View File

@ -1,4 +1,4 @@
use api::permissionsystem_capnp::permission_system::Server as PermissionSystem;
use api::permissionsystem_capnp::permission_system::info::Server as PermissionSystem;
use crate::session::SessionHandle;

View File

@ -1,4 +1,5 @@
use api::authenticationsystem_capnp::response::successful::Builder;
use crate::authorization::permissions::Permission;
use crate::capnp::machinesystem::Machines;
@ -17,8 +18,24 @@ impl APISession {
pub fn build(session: SessionHandle, builder: Builder) {
let mut builder = builder.init_session();
builder.set_machine_system(capnp_rpc::new_client(Machines::new(session.clone())));
builder.set_user_system(capnp_rpc::new_client(Users::new(session.clone())));
builder.set_permission_system(capnp_rpc::new_client(Permissions::new(session)));
{
let mut b = builder.reborrow().init_machine_system();
b.set_info(capnp_rpc::new_client(Machines::new(session.clone())));
}
{
let mut b = builder.reborrow().init_user_system();
let u = Users::new(session.clone());
if session.has_perm(Permission::new("bffh.users.manage")) {
b.set_manage(capnp_rpc::new_client(u.clone()));
}
b.set_info(capnp_rpc::new_client(u));
}
{
let mut b = builder.init_permission_system();
b.set_info(capnp_rpc::new_client(Permissions::new(session)));
}
}
}

View File

@ -2,7 +2,7 @@ use capnp::capability::Promise;
use capnp_rpc::pry;
use libc::user;
use api::usersystem_capnp::user_system::{
info, manage, Server as UserSystem,
info, manage,
self as system,
};
use crate::authorization::permissions::Permission;
@ -22,34 +22,13 @@ impl Users {
}
}
impl system::Server for Users {
fn info(
&mut self,
_: system::InfoParams,
mut result: system::InfoResults,
) -> Promise<(), ::capnp::Error> {
result.get().set_info(capnp_rpc::new_client(self.clone()));
Promise::ok(())
}
fn manage(
&mut self,
_: system::ManageParams,
mut result: system::ManageResults,
) -> Promise<(), ::capnp::Error> {
if self.session.has_perm(Permission::new("bffh.users.manage")) {
result.get().set_manage(capnp_rpc::new_client(self.clone()));
}
Promise::ok(())
}
}
impl info::Server for Users {
fn get_user_self(
&mut self,
_: info::GetUserSelfParams,
mut result: info::GetUserSelfResults,
) -> Promise<(), ::capnp::Error> {
let builder = result.get().init_user();
let builder = result.get();
User::build(self.session.clone(), builder);
Promise::ok(())
}

View File

@ -6,7 +6,7 @@ use rkyv::{Archive, Archived, Deserialize, Infallible};
use std::str::FromStr;
use crate::oidvalue;
//use crate::oidvalue;
use crate::resources::state::{State};
@ -137,4 +137,4 @@ pub static OID_TYPE: Lazy<ObjectIdentifier> =
Lazy::new(|| ObjectIdentifier::from_str("1.3.6.1.4.1.48398.612.1.14").unwrap());
pub static OID_VALUE: Lazy<ObjectIdentifier> =
Lazy::new(|| ObjectIdentifier::from_str("1.3.6.1.4.1.48398.612.2.4").unwrap());
oidvalue!(OID_TYPE, MachineState, ArchivedMachineState);
//oidvalue!(OID_TYPE, MachineState, ArchivedMachineState);

View File

@ -1,10 +1,7 @@
use std::{any::Any, fmt, hash::Hash, ptr, str::FromStr};
use ptr_meta::{DynMetadata, Pointee};
use rkyv::{
out_field, Archive, ArchivePointee, ArchiveUnsized, Archived, ArchivedMetadata, Deserialize,
DeserializeUnsized, Fallible, Serialize, SerializeUnsized,
};
use rkyv::{out_field, Archive, ArchivePointee, ArchiveUnsized, Archived, ArchivedMetadata, Deserialize, DeserializeUnsized, Fallible, Serialize, SerializeUnsized, RelPtr};
use rkyv_dyn::{DynDeserializer, DynError, DynSerializer};
@ -20,7 +17,396 @@ use std::alloc::Layout;
use std::collections::HashMap;
use std::fmt::Formatter;
use std::mem::MaybeUninit;
use std::ops::Deref;
use std::sync::atomic::{AtomicUsize, Ordering};
use rkyv::boxed::{ArchivedBox, BoxResolver};
use rkyv::vec::ArchivedVec;
#[repr(transparent)]
struct MetaBox<T: ?Sized>(Box<T>);
impl<T: ?Sized> From<Box<T>> for MetaBox<T> {
fn from(b: Box<T>) -> Self {
Self(b)
}
}
#[repr(transparent)]
struct ArchivedMetaBox<T: ArchivePointee + ?Sized>(RelPtr<T>);
impl<T: ArchivePointee + ?Sized> ArchivedMetaBox<T> {
#[inline]
pub fn get(&self) -> &T {
unsafe { &*self.0.as_ptr() }
}
}
impl<T: ArchivePointee + ?Sized> AsRef<T> for ArchivedMetaBox<T> {
fn as_ref(&self) -> &T {
self.get()
}
}
impl<T: ArchivePointee + ?Sized> Deref for ArchivedMetaBox<T> {
type Target = T;
#[inline]
fn deref(&self) -> &Self::Target {
self.get()
}
}
// State built as
struct NewStateBuilder {
inner: Vec<MetaBox<dyn SerializeStateValue>>,
}
// turns into
struct NewState {
inner: ArchivedVec<ArchivedMetaBox<dyn ArchivedStateValue>>
}
impl NewState {
pub fn get_value<T: TypeOid>(&self) -> Option<&T> {
/*
let target_oid = T::type_oid();
let values = self.inner.as_slice();
for v in values {
let oid: &Archived<ObjectIdentifier> = &v.metadata().type_oid;
if &target_oid.deref() == &oid.deref() {
let value = unsafe { &*v.as_ptr().cast() };
return Some(value);
}
}
None
*/
unimplemented!()
}
}
// for usage.
// The important part is that both `SerializeValue` and `Value` tell us their OIDs. State will
// usually consist of only a very small number of parts, most of the time just one, so linear
// search will be the best.
// `dyn Value` is Archived using custom sauce Metadata that will store the OID of the state
// value, allowing us to cast the object (reasonably) safely. Thus we can also add a
// method `get_part<T: Value>(&self) -> Option<&T>`
// ArchivedBox is just a RelPtr into the object; so we'd use an `ArchivedValue<NewDesignState>`.
// We can freely modify the memory of the value, so caching vtables is possible & sensible?
// For dumping / loading values using serde we have to be able to serialize a `dyn Value` and to
// deserialize a `dyn SerializeValue`.
// This means, for every type T that's a value we must have:
// - impl SerializeValue for T, which probably implies impl Value for T?
// - impl Value for Archived<T>
// - impl serde::Deserialize for T
// - impl serde::Serialize for Archived<T>
// - impl rkyv::Archive, rkyv::Serialize for T
#[ptr_meta::pointee]
/// Trait that values in the State Builder have to implement
///
/// It requires serde::Deserialize and rkyv::SerializeUnsized to be implemented.
///
/// it is assumed that there is a 1:1 mapping between a SerializeStateValue and a StateValue
/// implementation. Every `T` implementing the former has exactly *one* `Archived<T>` implementing
/// the latter.
///
/// The archived version of any implementation must implement [ArchivedStateValue](trait@ArchivedStateValue).
pub trait SerializeStateValue: SerializeDynOid {}
#[ptr_meta::pointee]
/// Trait that (rkyv'ed) values in the State Object have to implement.
///
/// It requires serde::Serialize to be implemented.
///
/// It must be Sync since the State is sent as a signal to all connected actors by reference.
/// It must be Send since the DB thread and the signal thread may be different.
pub trait ArchivedStateValue: Send + Sync {}
/// Serializing a trait object by storing an OID alongside
///
/// This trait is a dependency for [SerializeStateValue](trait@SerializeStateValue). It is by
/// default implemented for all `T where T: for<'a> Serialize<dyn DynSerializer + 'a>, T::Archived: TypeOid`.
pub trait SerializeDynOid {
/// Return the OID associated with the **Archived** type, i.e. `Archived<Self>`.
///
/// This OID will be serialized alongside the trait object and is used to retrieve the
/// correct vtable when loading the state from DB.
fn archived_type_oid(&self) -> &'static ObjectIdentifier;
/// Serialize this type into a [`DynSerializer`](trait@DynSerializer)
fn serialize_dynoid(&self, serializer: &mut dyn DynSerializer) -> Result<usize, DynError>;
}
/// Types with an associated OID
///
/// This trait is required by the default implementation of [SerializeDynOid](trait@SerializeDynOid),
/// providing the OID that is serialized alongside the state object to be able to correctly cast
/// it when accessing state from the DB.
pub trait TypeOid {
fn type_oid() -> &'static ObjectIdentifier;
fn type_name() -> &'static str;
}
impl<T> SerializeDynOid for T
where
T: for<'a> Serialize<dyn DynSerializer + 'a>,
T::Archived: TypeOid,
{
fn archived_type_oid(&self) -> &'static ObjectIdentifier {
Archived::<T>::type_oid()
}
fn serialize_dynoid(&self, serializer: &mut dyn DynSerializer) -> Result<usize, DynError> {
serializer.serialize_value(self)
}
}
impl ArchivePointee for dyn ArchivedStateValue {
type ArchivedMetadata = ArchivedStateValueMetadata;
fn pointer_metadata(archived: &Self::ArchivedMetadata) -> <Self as Pointee>::Metadata {
archived.pointer_metadata()
}
}
impl ArchiveUnsized for dyn SerializeStateValue {
type Archived = dyn ArchivedStateValue;
type MetadataResolver = <ObjectIdentifier as Archive>::Resolver;
unsafe fn resolve_metadata(
&self,
pos: usize,
resolver: Self::MetadataResolver,
out: *mut ArchivedMetadata<Self>, // => ArchivedStateValueMetadata
) {
let (oid_pos, oid) = out_field!(out.type_oid);
let type_oid = self.archived_type_oid();
type_oid.resolve(pos + oid_pos, resolver, oid);
let (_vtable_cache_pos, vtable_cache) = out_field!(out.vtable_cache);
*vtable_cache = AtomicUsize::default();
}
}
impl<S: ScratchSpace + Serializer + ?Sized> SerializeUnsized<S> for dyn SerializeStateValue {
fn serialize_unsized(&self, mut serializer: &mut S) -> Result<usize, S::Error> {
self.serialize_dynoid(&mut serializer)
.map_err(|e| *e.downcast::<S::Error>().unwrap())
}
fn serialize_metadata(&self, serializer: &mut S) -> Result<Self::MetadataResolver, S::Error> {
let oid = self.archived_type_oid();
oid.serialize(serializer)
}
}
#[derive(Debug)]
pub struct ArchivedStateValueMetadata {
pub type_oid: Archived<ObjectIdentifier>,
vtable_cache: AtomicUsize,
}
impl ArchivedStateValueMetadata {
// TODO: `usize as *const VTable` is not sane.
pub fn vtable(&self) -> usize {
let val = self.vtable_cache.load(Ordering::Relaxed);
if val != 0 {
return val;
}
let val = IMPL_REGISTRY
.get(ImplId::from_type_oid(&self.type_oid))
.expect(&format!("Unregistered type oid {:?}", self.type_oid))
.vtable;
self.vtable_cache.store(val, Ordering::Relaxed);
return val;
}
pub fn pointer_metadata(&self) -> DynMetadata<dyn ArchivedStateValue> {
unsafe { core::mem::transmute(self.vtable()) }
}
}
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
/// OID of an [ArchivedStateValue](trait@ArchivedStateValue) implementation.
///
/// Used by the global type registry of all implementations to look up the vtables of state values
/// when accessing it from DB and when (de-)serializing it using serde.
struct ImplId<'a> {
type_oid: &'a [u8],
}
impl<'a> ImplId<'a> {
fn from_type_oid(type_oid: &'a [u8]) -> Self {
Self { type_oid }
}
}
impl ImplId<'static> {
fn new<T: TypeOid>() -> Self {
Self {
type_oid: &T::type_oid(),
}
}
}
#[derive(Copy, Clone, Debug)]
struct ImplData<'a> {
pub vtable: usize,
pub name: &'a str,
pub info: ImplDebugInfo,
}
#[derive(Copy, Clone, Debug)]
pub struct ImplDebugInfo {
pub file: &'static str,
pub line: u32,
pub column: u32,
}
#[derive(Debug)]
/// State Value Implementation Entry
///
/// To register a state implementation you must call [inventory::collect](macro@inventory::collect)
/// macro for an Entry constructed for your type on top level. Your type will have to have
/// implementations of [TypeOid](trait@TypeOid) and [RegisteredImpl](trait@RegisteredImpl)
/// Alternatively you can use the
/// [statevalue_register](macro@crate::statevalue_register) macro with your OID as first and type
/// as second parameter like so:
///
/// ```no_run
/// struct MyStruct;
/// statevalue_register!(ObjectIdentifier::from_str("1.3.6.1.4.1.48398.612.1.14").unwrap(), MyStruct)
/// ```
pub struct ImplEntry<'a> {
id: ImplId<'a>,
data: ImplData<'a>,
}
inventory::collect!(ImplEntry<'static>);
impl ImplEntry<'_> {
pub fn new<T: TypeOid + RegisteredImpl>() -> Self {
Self {
id: ImplId::new::<T>(),
data: ImplData {
vtable: <T as RegisteredImpl>::vtable(),
name: <T as TypeOid>::type_name(),
info: <T as RegisteredImpl>::debug_info(),
},
}
}
}
#[derive(Debug)]
struct ImplRegistry {
oid_to_data: HashMap<ImplId<'static>, ImplData<'static>>,
}
impl ImplRegistry {
fn new() -> Self {
Self {
oid_to_data: HashMap::new(),
}
}
fn add_entry(&mut self, entry: &'static ImplEntry) {
let old_val = self.oid_to_data.insert(entry.id, entry.data);
if let Some(old) = old_val {
eprintln!("Value impl oid conflict for {:?}", entry.id.type_oid);
eprintln!(
"Existing impl registered at {}:{}:{}",
old.info.file, old.info.line, old.info.column
);
eprintln!(
"New impl registered at {}:{}:{}",
entry.data.info.file, entry.data.info.line, entry.data.info.column
);
}
}
fn get(&self, type_oid: ImplId) -> Option<ImplData> {
self.oid_to_data.get(&type_oid).map(|d| *d)
}
}
lazy_static::lazy_static! {
// FIXME: Dynamic modules *will* break this.
static ref IMPL_REGISTRY: ImplRegistry = {
let mut reg = ImplRegistry::new();
for entry in inventory::iter::<ImplEntry> {
reg.add_entry(entry);
}
reg
};
}
pub unsafe trait RegisteredImpl {
fn vtable() -> usize;
fn debug_info() -> ImplDebugInfo;
}
#[doc(hidden)]
#[macro_use]
pub mod macros {
#[macro_export]
macro_rules! debug_info {
() => {
$crate::resources::state::value::ImplDebugInfo {
file: ::core::file!(),
line: ::core::line!(),
column: ::core::column!(),
}
};
}
#[macro_export]
macro_rules! statevalue_typeoid {
( $x:ident, $y:ty, $z:ty ) => {
impl $crate::resources::state::value::TypeOid for $z {
fn type_oid() -> &'static $crate::utils::oid::ObjectIdentifier {
&$x
}
fn type_name() -> &'static str {
stringify!($y)
}
}
}
}
#[macro_export]
macro_rules! statevalue_registeredimpl {
( $z:ty ) => {
unsafe impl $crate::resources::state::value::RegisteredImpl for $z {
fn vtable() -> usize {
unsafe {
::core::mem::transmute(ptr_meta::metadata(
::core::ptr::null::<$z>() as *const dyn $crate::resources::state::value::ArchivedStateValue
))
}
}
fn debug_info() -> $crate::resources::state::value::ImplDebugInfo {
$crate::debug_info!()
}
}
}
}
#[macro_export]
macro_rules! statevalue_register {
( $x:ident, $y:ty ) => {
$crate::oidvalue! {$x, $y, $y}
};
( $x:ident, $y:ty, $z:ty ) => {
$crate::statevalue_typeoid! { $x, $y, $z }
$crate::statevalue_registeredimpl! { $z }
::inventory::submit! {$crate::resources::state::value::ImplEntry::new::<$z>()}
};
}
}
/*
/// Adding a custom type to BFFH state management:
///
/// 1. Implement `serde`'s [`Serialize`](serde::Serialize) and [`Deserialize`](serde::Deserialize)
@ -204,7 +590,6 @@ impl<'de> serde::de::DeserializeSeed<'de> for InitIntoSelf {
pub trait TypeOid {
fn type_oid() -> &'static ObjectIdentifier;
fn type_name() -> &'static str;
fn type_desc() -> &'static str;
}
impl<S: ScratchSpace + Serializer + ?Sized> SerializeUnsized<S> for dyn SerializeValue {
@ -219,12 +604,6 @@ impl<S: ScratchSpace + Serializer + ?Sized> SerializeUnsized<S> for dyn Serializ
}
}
/// Serialize dynamic types by storing an OID alongside
pub trait SerializeDynOid {
fn serialize_dynoid(&self, serializer: &mut dyn DynSerializer) -> Result<usize, DynError>;
fn archived_type_oid(&self) -> &'static ObjectIdentifier;
}
impl<T> SerializeDynOid for T
where
T: for<'a> Serialize<dyn DynSerializer + 'a>,
@ -254,16 +633,12 @@ pub trait DeserializeDynOid {
#[ptr_meta::pointee]
pub trait SerializeValue: Value + SerializeDynOid {
fn dyn_clone(&self) -> Box<dyn SerializeValue>;
}
impl<T: Archive + Value + SerializeDynOid + Clone> SerializeValue for T
where
T::Archived: RegisteredImpl,
{
fn dyn_clone(&self) -> Box<dyn SerializeValue> {
Box::new(self.clone())
}
}
impl PartialEq for dyn SerializeValue {
@ -323,230 +698,9 @@ impl ArchiveUnsized for dyn SerializeValue {
}
}
#[derive(Debug)]
pub struct ArchivedValueMetadata {
pub type_oid: Archived<ObjectIdentifier>,
}
impl ArchivedValueMetadata {
pub unsafe fn emplace(type_oid: Archived<ObjectIdentifier>, out: *mut Self) {
let p = ptr::addr_of_mut!((*out).type_oid);
ptr::write(p, type_oid);
}
pub fn vtable(&self) -> usize {
IMPL_REGISTRY
.get(ImplId::from_type_oid(&self.type_oid))
.expect(&format!(
"Unregistered \
type \
oid \
{:?}",
self.type_oid
))
.vtable
}
pub fn pointer_metadata(&self) -> DynMetadata<dyn DeserializeValue> {
unsafe { core::mem::transmute(self.vtable()) }
}
}
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
pub struct ImplId<'a> {
type_oid: &'a [u8],
}
impl<'a> ImplId<'a> {
pub fn from_type_oid(type_oid: &'a [u8]) -> Self {
Self { type_oid }
}
}
impl ImplId<'static> {
fn new<T: TypeOid>() -> Self {
Self {
type_oid: &T::type_oid(),
}
}
}
#[derive(Copy, Clone, Debug)]
struct ImplData<'a> {
pub vtable: usize,
pub name: &'a str,
pub desc: &'a str,
pub info: ImplDebugInfo,
}
#[derive(Copy, Clone, Debug)]
#[doc(hidden)]
pub struct ImplDebugInfo {
pub file: &'static str,
pub line: u32,
pub column: u32,
}
impl ImplData<'_> {
pub unsafe fn pointer_metadata<T: ?Sized>(&self) -> DynMetadata<T> {
core::mem::transmute(self.vtable)
}
}
#[derive(Debug)]
pub struct ImplEntry<'a> {
id: ImplId<'a>,
data: ImplData<'a>,
}
inventory::collect!(ImplEntry<'static>);
impl ImplEntry<'_> {
#[doc(hidden)]
pub fn new<T: TypeOid + RegisteredImpl>() -> Self {
Self {
id: ImplId::new::<T>(),
data: ImplData {
vtable: <T as RegisteredImpl>::vtable(),
name: <T as TypeOid>::type_name(),
desc: <T as TypeOid>::type_desc(),
info: <T as RegisteredImpl>::debug_info(),
},
}
}
}
#[derive(Debug)]
struct ImplRegistry {
oid_to_data: HashMap<ImplId<'static>, ImplData<'static>>,
}
impl ImplRegistry {
fn new() -> Self {
Self {
oid_to_data: HashMap::new(),
}
}
fn add_entry(&mut self, entry: &'static ImplEntry) {
let old_val = self.oid_to_data.insert(entry.id, entry.data);
if let Some(old) = old_val {
eprintln!("Value impl oid conflict for {:?}", entry.id.type_oid);
eprintln!(
"Existing impl registered at {}:{}:{}",
old.info.file, old.info.line, old.info.column
);
eprintln!(
"New impl registered at {}:{}:{}",
entry.data.info.file, entry.data.info.line, entry.data.info.column
);
}
assert!(old_val.is_none());
}
fn get(&self, type_oid: ImplId) -> Option<ImplData> {
self.oid_to_data.get(&type_oid).map(|d| *d)
}
}
lazy_static::lazy_static! {
// FIXME: Dynamic modules *will* break this.
static ref IMPL_REGISTRY: ImplRegistry = {
let mut reg = ImplRegistry::new();
for entry in inventory::iter::<ImplEntry> {
reg.add_entry(entry);
}
reg
};
}
pub unsafe trait RegisteredImpl {
fn vtable() -> usize;
fn debug_info() -> ImplDebugInfo;
}
#[macro_use]
pub mod macros {
#[macro_export]
macro_rules! debug_info {
() => {
$crate::resources::state::value::ImplDebugInfo {
file: ::core::file!(),
line: ::core::line!(),
column: ::core::column!(),
}
};
}
#[macro_export]
macro_rules! oiddeser {
( $y:ty, $z:ty ) => {
impl $crate::resources::state::value::DeserializeDynOid for $y
where
$y: for<'a> ::rkyv::Deserialize<$z, (dyn ::rkyv_dyn::DynDeserializer + 'a)>,
{
unsafe fn deserialize_dynoid(
&self,
deserializer: &mut dyn ::rkyv_dyn::DynDeserializer,
alloc: &mut dyn FnMut(::core::alloc::Layout) -> *mut u8,
) -> Result<*mut (), ::rkyv_dyn::DynError> {
let ptr = alloc(::core::alloc::Layout::new::<$z>()).cast::<$z>();
ptr.write(self.deserialize(deserializer)?);
Ok(ptr as *mut ())
}
fn deserialize_dynoid_metadata(
&self,
_: &mut dyn ::rkyv_dyn::DynDeserializer,
) -> ::std::result::Result<<dyn $crate::resources::state::value::SerializeValue
as
::ptr_meta::Pointee>::Metadata, ::rkyv_dyn::DynError> {
unsafe {
Ok(core::mem::transmute(ptr_meta::metadata(
::core::ptr::null::<$z>() as *const dyn $crate::resources::state::value::SerializeValue,
)))
}
}
}
};
}
#[macro_export]
macro_rules! oidvalue {
( $x:ident, $y:ty ) => {
$crate::oidvalue! {$x, $y, $y}
};
( $x:ident, $y:ty, $z:ty ) => {
$crate::oiddeser! {$z, $y}
impl $crate::resources::state::value::TypeOid for $z {
fn type_oid() -> &'static $crate::utils::oid::ObjectIdentifier {
&$x
}
fn type_name() -> &'static str {
stringify!($y)
}
fn type_desc() -> &'static str {
"builtin"
}
}
unsafe impl $crate::resources::state::value::RegisteredImpl for $z {
fn vtable() -> usize {
unsafe {
::core::mem::transmute(ptr_meta::metadata(
::core::ptr::null::<$z>() as *const dyn $crate::resources::state::value::DeserializeValue
))
}
}
fn debug_info() -> $crate::resources::state::value::ImplDebugInfo {
$crate::debug_info!()
}
}
::inventory::submit! {$crate::resources::state::value::ImplEntry::new::<$z>()}
};
}
}
lazy_static::lazy_static! {
@ -646,3 +800,5 @@ mod tests {
}
}
}
*/

View File

@ -23,7 +23,7 @@
-- If bffh can not bind a port for the specified combination if will log an error but *continue with the remaining ports*
{ address = "127.0.0.1", port = 59661 },
{ address = "::1", port = 59661 },
{ address = "192.168.0.114", port = 59661 }
{ address = "steak.fritz.box", port = 59661 }
],
-- Configure TLS. BFFH requires a PEM-encoded certificate and the associated key as two separate files