From 541b9b22d2b806c7869f2b739e10c9a33cb5ec64 Mon Sep 17 00:00:00 2001 From: kjuulh Date: Sun, 27 Aug 2023 20:16:27 +0200 Subject: [PATCH] chore: change to byte slice Signed-off-by: kjuulh --- crates/churn-capnp/schemas/models.capnp | 5 + crates/churn-capnp/src/lib.rs | 37 +- crates/churn-capnp/src/models_capnp.rs | 1393 ++++++++++++----------- crates/churn-domain/src/lib.rs | 6 + crates/churn-server/src/agent.rs | 7 - crates/churn-server/src/db.rs | 14 +- crates/churn-server/src/event.rs | 8 +- crates/churn-server/src/lease.rs | 40 +- crates/churn-server/src/main.rs | 59 +- crates/churning/src/main.rs | 6 +- 10 files changed, 829 insertions(+), 746 deletions(-) diff --git a/crates/churn-capnp/schemas/models.capnp b/crates/churn-capnp/schemas/models.capnp index 96c914f..c6fe4cb 100644 --- a/crates/churn-capnp/schemas/models.capnp +++ b/crates/churn-capnp/schemas/models.capnp @@ -10,3 +10,8 @@ struct LogEvent { struct Agent { name @0 :Text; } + +struct Lease { + id @0 :Text; + lease @1 :Text; +} diff --git a/crates/churn-capnp/src/lib.rs b/crates/churn-capnp/src/lib.rs index ca60a43..44a6a73 100644 --- a/crates/churn-capnp/src/lib.rs +++ b/crates/churn-capnp/src/lib.rs @@ -3,7 +3,7 @@ use capnp::message::{ReaderOptions, TypedReader}; use capnp::serialize::{self, SliceSegments}; use capnp::traits::Owned; -use churn_domain::{Agent, LogEvent}; +use churn_domain::{Agent, Lease, LogEvent}; mod models_capnp; @@ -11,19 +11,18 @@ pub trait CapnpPackExt { type Return; fn serialize_capnp(&self) -> Vec; - fn deserialize_capnp(content: &Vec) -> anyhow::Result; + fn deserialize_capnp(content: &[u8]) -> anyhow::Result; fn capnp_to_string(builder: &Builder) -> Vec { serialize::write_message_to_words(builder) } - fn string_to_capnp(content: &Vec) -> TypedReader + fn string_to_capnp(mut content: &[u8]) -> TypedReader where S: Owned, { let log_event = - serialize::read_message_from_flat_slice(&mut content.as_slice(), ReaderOptions::new()) - .unwrap(); + serialize::read_message_from_flat_slice(&mut content, ReaderOptions::new()).unwrap(); log_event.into_typed::() } @@ -43,7 +42,7 @@ impl CapnpPackExt for LogEvent { Self::capnp_to_string(&builder) } - fn deserialize_capnp(content: &Vec) -> anyhow::Result { + fn deserialize_capnp(content: &[u8]) -> anyhow::Result { let log_event = Self::string_to_capnp::(content); let log_event = log_event.get()?; @@ -71,7 +70,7 @@ impl CapnpPackExt for Agent { Self::capnp_to_string(&builder) } - fn deserialize_capnp(content: &Vec) -> anyhow::Result { + fn deserialize_capnp(content: &[u8]) -> anyhow::Result { let item = Self::string_to_capnp::(content); let item = item.get()?; @@ -80,3 +79,27 @@ impl CapnpPackExt for Agent { }) } } + +impl CapnpPackExt for Lease { + type Return = Self; + + fn serialize_capnp(&self) -> Vec { + let mut builder = Builder::new_default(); + let mut item = builder.init_root::(); + + item.set_id(&self.id.to_string()); + item.set_lease(&self.lease.to_string()); + + Self::capnp_to_string(&builder) + } + + fn deserialize_capnp(content: &[u8]) -> anyhow::Result { + let item = Self::string_to_capnp::(content); + let item = item.get()?; + + Ok(Self { + id: uuid::Uuid::parse_str(item.get_id()?)?, + lease: uuid::Uuid::parse_str(item.get_lease()?)?, + }) + } +} diff --git a/crates/churn-capnp/src/models_capnp.rs b/crates/churn-capnp/src/models_capnp.rs index 5b75d78..0754422 100644 --- a/crates/churn-capnp/src/models_capnp.rs +++ b/crates/churn-capnp/src/models_capnp.rs @@ -2,701 +2,764 @@ // DO NOT EDIT. // source: models.capnp + pub mod log_event { - #[derive(Copy, Clone)] - pub struct Owned(()); - impl ::capnp::introspect::Introspect for Owned { - fn introspect() -> ::capnp::introspect::Type { - ::capnp::introspect::TypeVariant::Struct(::capnp::introspect::RawBrandedStructSchema { - generic: &_private::RAW_SCHEMA, - field_types: _private::get_field_types, - annotation_types: _private::get_annotation_types, - }) - .into() - } + #[derive(Copy, Clone)] + pub struct Owned(()); + impl ::capnp::introspect::Introspect for Owned { fn introspect() -> ::capnp::introspect::Type { ::capnp::introspect::TypeVariant::Struct(::capnp::introspect::RawBrandedStructSchema { generic: &_private::RAW_SCHEMA, field_types: _private::get_field_types, annotation_types: _private::get_annotation_types }).into() } } + impl ::capnp::traits::Owned for Owned { type Reader<'a> = Reader<'a>; type Builder<'a> = Builder<'a>; } + impl ::capnp::traits::OwnedStruct for Owned { type Reader<'a> = Reader<'a>; type Builder<'a> = Builder<'a>; } + impl ::capnp::traits::Pipelined for Owned { type Pipeline = Pipeline; } + + pub struct Reader<'a> { reader: ::capnp::private::layout::StructReader<'a> } + impl <'a,> ::core::marker::Copy for Reader<'a,> {} + impl <'a,> ::core::clone::Clone for Reader<'a,> { + fn clone(&self) -> Self { *self } + } + + impl <'a,> ::capnp::traits::HasTypeId for Reader<'a,> { + const TYPE_ID: u64 = _private::TYPE_ID; + } + impl <'a,> ::core::convert::From<::capnp::private::layout::StructReader<'a>> for Reader<'a,> { + fn from(reader: ::capnp::private::layout::StructReader<'a>) -> Self { + Self { reader, } } - impl ::capnp::traits::Owned for Owned { - type Reader<'a> = Reader<'a>; - type Builder<'a> = Builder<'a>; + } + + impl <'a,> ::core::convert::From> for ::capnp::dynamic_value::Reader<'a> { + fn from(reader: Reader<'a,>) -> Self { + Self::Struct(::capnp::dynamic_struct::Reader::new(reader.reader, ::capnp::schema::StructSchema::new(::capnp::introspect::RawBrandedStructSchema { generic: &_private::RAW_SCHEMA, field_types: _private::get_field_types::<>, annotation_types: _private::get_annotation_types::<>}))) } - impl ::capnp::traits::OwnedStruct for Owned { - type Reader<'a> = Reader<'a>; - type Builder<'a> = Builder<'a>; + } + + impl <'a,> ::core::fmt::Debug for Reader<'a,> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::result::Result<(), ::core::fmt::Error> { + core::fmt::Debug::fmt(&::core::convert::Into::<::capnp::dynamic_value::Reader<'_>>::into(*self), f) } - impl ::capnp::traits::Pipelined for Owned { - type Pipeline = Pipeline; + } + + 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 { + ::core::result::Result::Ok(reader.get_struct(default)?.into()) + } + } + + 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<'_,> { + Self { .. *self } } - pub struct Reader<'a> { - reader: ::capnp::private::layout::StructReader<'a>, + pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> { + self.reader.total_size() } - impl<'a> ::core::marker::Copy for Reader<'a> {} - impl<'a> ::core::clone::Clone for Reader<'a> { - fn clone(&self) -> Self { - *self - } + #[inline] + pub fn get_id(self) -> ::capnp::Result<::capnp::text::Reader<'a>> { + ::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(0), ::core::option::Option::None) + } + #[inline] + pub fn has_id(&self) -> bool { + !self.reader.get_pointer_field(0).is_null() + } + #[inline] + pub fn get_author(self) -> ::capnp::Result<::capnp::text::Reader<'a>> { + ::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(1), ::core::option::Option::None) + } + #[inline] + pub fn has_author(&self) -> bool { + !self.reader.get_pointer_field(1).is_null() + } + #[inline] + pub fn get_content(self) -> ::capnp::Result<::capnp::text::Reader<'a>> { + ::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(2), ::core::option::Option::None) + } + #[inline] + pub fn has_content(&self) -> bool { + !self.reader.get_pointer_field(2).is_null() + } + #[inline] + pub fn get_datetime(self) -> i64 { + self.reader.get_data_field::(0) + } + } + + pub struct Builder<'a> { builder: ::capnp::private::layout::StructBuilder<'a> } + impl <'a,> ::capnp::traits::HasStructSize for Builder<'a,> { + const STRUCT_SIZE: ::capnp::private::layout::StructSize = ::capnp::private::layout::StructSize { data: 1, pointers: 3 }; + } + impl <'a,> ::capnp::traits::HasTypeId for Builder<'a,> { + const TYPE_ID: u64 = _private::TYPE_ID; + } + impl <'a,> ::core::convert::From<::capnp::private::layout::StructBuilder<'a>> for Builder<'a,> { + fn from(builder: ::capnp::private::layout::StructBuilder<'a>) -> Self { + Self { builder, } + } + } + + impl <'a,> ::core::convert::From> for ::capnp::dynamic_value::Builder<'a> { + fn from(builder: Builder<'a,>) -> Self { + Self::Struct(::capnp::dynamic_struct::Builder::new(builder.builder, ::capnp::schema::StructSchema::new(::capnp::introspect::RawBrandedStructSchema { generic: &_private::RAW_SCHEMA, field_types: _private::get_field_types::<>, annotation_types: _private::get_annotation_types::<>}))) + } + } + + 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) -> Self { + builder.init_struct(::STRUCT_SIZE).into() + } + fn get_from_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>, default: ::core::option::Option<&'a [::capnp::Word]>) -> ::capnp::Result { + ::core::result::Result::Ok(builder.get_struct(::STRUCT_SIZE, default)?.into()) + } + } + + impl <'a,> ::capnp::traits::SetPointerBuilder for Reader<'a,> { + fn set_pointer_builder(mut pointer: ::capnp::private::layout::PointerBuilder<'_>, value: Self, canonicalize: bool) -> ::capnp::Result<()> { pointer.set_struct(&value.reader, canonicalize) } + } + + impl <'a,> Builder<'a,> { + pub fn into_reader(self) -> Reader<'a,> { + self.builder.into_reader().into() + } + pub fn reborrow(&mut self) -> Builder<'_,> { + Builder { builder: self.builder.reborrow() } + } + pub fn reborrow_as_reader(&self) -> Reader<'_,> { + self.builder.as_reader().into() } - impl<'a> ::capnp::traits::HasTypeId for Reader<'a> { - const TYPE_ID: u64 = _private::TYPE_ID; + pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> { + self.builder.as_reader().total_size() } - impl<'a> ::core::convert::From<::capnp::private::layout::StructReader<'a>> for Reader<'a> { - fn from(reader: ::capnp::private::layout::StructReader<'a>) -> Self { - Self { reader } - } + #[inline] + pub fn get_id(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_id(&mut self, value: ::capnp::text::Reader<'_>) { + self.builder.reborrow().get_pointer_field(0).set_text(value); + } + #[inline] + pub fn init_id(self, size: u32) -> ::capnp::text::Builder<'a> { + self.builder.get_pointer_field(0).init_text(size) + } + #[inline] + pub fn has_id(&self) -> bool { + !self.builder.is_pointer_field_null(0) + } + #[inline] + pub fn get_author(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_author(&mut self, value: ::capnp::text::Reader<'_>) { + self.builder.reborrow().get_pointer_field(1).set_text(value); + } + #[inline] + pub fn init_author(self, size: u32) -> ::capnp::text::Builder<'a> { + self.builder.get_pointer_field(1).init_text(size) + } + #[inline] + pub fn has_author(&self) -> bool { + !self.builder.is_pointer_field_null(1) + } + #[inline] + pub fn get_content(self) -> ::capnp::Result<::capnp::text::Builder<'a>> { + ::capnp::traits::FromPointerBuilder::get_from_pointer(self.builder.get_pointer_field(2), ::core::option::Option::None) + } + #[inline] + pub fn set_content(&mut self, value: ::capnp::text::Reader<'_>) { + self.builder.reborrow().get_pointer_field(2).set_text(value); + } + #[inline] + pub fn init_content(self, size: u32) -> ::capnp::text::Builder<'a> { + self.builder.get_pointer_field(2).init_text(size) + } + #[inline] + pub fn has_content(&self) -> bool { + !self.builder.is_pointer_field_null(2) + } + #[inline] + pub fn get_datetime(self) -> i64 { + self.builder.get_data_field::(0) + } + #[inline] + pub fn set_datetime(&mut self, value: i64) { + self.builder.set_data_field::(0, value); + } + } - impl<'a> ::core::convert::From> for ::capnp::dynamic_value::Reader<'a> { - fn from(reader: Reader<'a>) -> Self { - Self::Struct(::capnp::dynamic_struct::Reader::new( - reader.reader, - ::capnp::schema::StructSchema::new(::capnp::introspect::RawBrandedStructSchema { - generic: &_private::RAW_SCHEMA, - field_types: _private::get_field_types, - annotation_types: _private::get_annotation_types, - }), - )) - } + pub struct Pipeline { _typeless: ::capnp::any_pointer::Pipeline } + impl ::capnp::capability::FromTypelessPipeline for Pipeline { + fn new(typeless: ::capnp::any_pointer::Pipeline) -> Self { + Self { _typeless: typeless, } } - - impl<'a> ::core::fmt::Debug for Reader<'a> { - fn fmt( - &self, - f: &mut ::core::fmt::Formatter<'_>, - ) -> ::core::result::Result<(), ::core::fmt::Error> { - core::fmt::Debug::fmt( - &::core::convert::Into::<::capnp::dynamic_value::Reader<'_>>::into(*self), - f, - ) - } + } + impl Pipeline { + } + mod _private { + pub static ENCODED_NODE: [::capnp::Word; 78] = [ + ::capnp::word(0, 0, 0, 0, 5, 0, 6, 0), + ::capnp::word(50, 25, 14, 89, 91, 12, 143, 231), + ::capnp::word(13, 0, 0, 0, 1, 0, 1, 0), + ::capnp::word(164, 172, 216, 255, 36, 223, 58, 242), + ::capnp::word(3, 0, 7, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(21, 0, 0, 0, 178, 0, 0, 0), + ::capnp::word(29, 0, 0, 0, 7, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(25, 0, 0, 0, 231, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(109, 111, 100, 101, 108, 115, 46, 99), + ::capnp::word(97, 112, 110, 112, 58, 76, 111, 103), + ::capnp::word(69, 118, 101, 110, 116, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 1, 0, 1, 0), + ::capnp::word(16, 0, 0, 0, 3, 0, 4, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 1, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(97, 0, 0, 0, 26, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(92, 0, 0, 0, 3, 0, 1, 0), + ::capnp::word(104, 0, 0, 0, 2, 0, 1, 0), + ::capnp::word(1, 0, 0, 0, 1, 0, 0, 0), + ::capnp::word(0, 0, 1, 0, 1, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(101, 0, 0, 0, 58, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(96, 0, 0, 0, 3, 0, 1, 0), + ::capnp::word(108, 0, 0, 0, 2, 0, 1, 0), + ::capnp::word(2, 0, 0, 0, 2, 0, 0, 0), + ::capnp::word(0, 0, 1, 0, 2, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(105, 0, 0, 0, 66, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(100, 0, 0, 0, 3, 0, 1, 0), + ::capnp::word(112, 0, 0, 0, 2, 0, 1, 0), + ::capnp::word(3, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 1, 0, 3, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(109, 0, 0, 0, 74, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(108, 0, 0, 0, 3, 0, 1, 0), + ::capnp::word(120, 0, 0, 0, 2, 0, 1, 0), + ::capnp::word(105, 100, 0, 0, 0, 0, 0, 0), + ::capnp::word(12, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(12, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(97, 117, 116, 104, 111, 114, 0, 0), + ::capnp::word(12, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(12, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(99, 111, 110, 116, 101, 110, 116, 0), + ::capnp::word(12, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(12, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(100, 97, 116, 101, 116, 105, 109, 101), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(5, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(5, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ]; + pub fn get_field_types(index: u16) -> ::capnp::introspect::Type { + match index { + 0 => <::capnp::text::Owned as ::capnp::introspect::Introspect>::introspect(), + 1 => <::capnp::text::Owned as ::capnp::introspect::Introspect>::introspect(), + 2 => <::capnp::text::Owned as ::capnp::introspect::Introspect>::introspect(), + 3 => ::introspect(), + _ => panic!("invalid field index {}", index), + } } - - 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 { - ::core::result::Result::Ok(reader.get_struct(default)?.into()) - } - } - - 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<'_> { - Self { ..*self } - } - - pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> { - self.reader.total_size() - } - #[inline] - pub fn get_id(self) -> ::capnp::Result<::capnp::text::Reader<'a>> { - ::capnp::traits::FromPointerReader::get_from_pointer( - &self.reader.get_pointer_field(0), - ::core::option::Option::None, - ) - } - #[inline] - pub fn has_id(&self) -> bool { - !self.reader.get_pointer_field(0).is_null() - } - #[inline] - pub fn get_author(self) -> ::capnp::Result<::capnp::text::Reader<'a>> { - ::capnp::traits::FromPointerReader::get_from_pointer( - &self.reader.get_pointer_field(1), - ::core::option::Option::None, - ) - } - #[inline] - pub fn has_author(&self) -> bool { - !self.reader.get_pointer_field(1).is_null() - } - #[inline] - pub fn get_content(self) -> ::capnp::Result<::capnp::text::Reader<'a>> { - ::capnp::traits::FromPointerReader::get_from_pointer( - &self.reader.get_pointer_field(2), - ::core::option::Option::None, - ) - } - #[inline] - pub fn has_content(&self) -> bool { - !self.reader.get_pointer_field(2).is_null() - } - #[inline] - pub fn get_datetime(self) -> i64 { - self.reader.get_data_field::(0) - } - } - - pub struct Builder<'a> { - builder: ::capnp::private::layout::StructBuilder<'a>, - } - impl<'a> ::capnp::traits::HasStructSize for Builder<'a> { - const STRUCT_SIZE: ::capnp::private::layout::StructSize = - ::capnp::private::layout::StructSize { - data: 1, - pointers: 3, - }; - } - impl<'a> ::capnp::traits::HasTypeId for Builder<'a> { - const TYPE_ID: u64 = _private::TYPE_ID; - } - impl<'a> ::core::convert::From<::capnp::private::layout::StructBuilder<'a>> for Builder<'a> { - fn from(builder: ::capnp::private::layout::StructBuilder<'a>) -> Self { - Self { builder } - } - } - - impl<'a> ::core::convert::From> for ::capnp::dynamic_value::Builder<'a> { - fn from(builder: Builder<'a>) -> Self { - Self::Struct(::capnp::dynamic_struct::Builder::new( - builder.builder, - ::capnp::schema::StructSchema::new(::capnp::introspect::RawBrandedStructSchema { - generic: &_private::RAW_SCHEMA, - field_types: _private::get_field_types, - annotation_types: _private::get_annotation_types, - }), - )) - } - } - - 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) -> Self { - builder - .init_struct(::STRUCT_SIZE) - .into() - } - fn get_from_pointer( - builder: ::capnp::private::layout::PointerBuilder<'a>, - default: ::core::option::Option<&'a [::capnp::Word]>, - ) -> ::capnp::Result { - ::core::result::Result::Ok( - builder - .get_struct( - ::STRUCT_SIZE, - default, - )? - .into(), - ) - } - } - - impl<'a> ::capnp::traits::SetPointerBuilder for Reader<'a> { - fn set_pointer_builder( - mut pointer: ::capnp::private::layout::PointerBuilder<'_>, - value: Self, - canonicalize: bool, - ) -> ::capnp::Result<()> { - pointer.set_struct(&value.reader, canonicalize) - } - } - - impl<'a> Builder<'a> { - pub fn into_reader(self) -> Reader<'a> { - self.builder.into_reader().into() - } - pub fn reborrow(&mut self) -> Builder<'_> { - Builder { - builder: self.builder.reborrow(), - } - } - pub fn reborrow_as_reader(&self) -> Reader<'_> { - self.builder.as_reader().into() - } - - pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> { - self.builder.as_reader().total_size() - } - #[inline] - pub fn get_id(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_id(&mut self, value: ::capnp::text::Reader<'_>) { - self.builder.reborrow().get_pointer_field(0).set_text(value); - } - #[inline] - pub fn init_id(self, size: u32) -> ::capnp::text::Builder<'a> { - self.builder.get_pointer_field(0).init_text(size) - } - #[inline] - pub fn has_id(&self) -> bool { - !self.builder.is_pointer_field_null(0) - } - #[inline] - pub fn get_author(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_author(&mut self, value: ::capnp::text::Reader<'_>) { - self.builder.reborrow().get_pointer_field(1).set_text(value); - } - #[inline] - pub fn init_author(self, size: u32) -> ::capnp::text::Builder<'a> { - self.builder.get_pointer_field(1).init_text(size) - } - #[inline] - pub fn has_author(&self) -> bool { - !self.builder.is_pointer_field_null(1) - } - #[inline] - pub fn get_content(self) -> ::capnp::Result<::capnp::text::Builder<'a>> { - ::capnp::traits::FromPointerBuilder::get_from_pointer( - self.builder.get_pointer_field(2), - ::core::option::Option::None, - ) - } - #[inline] - pub fn set_content(&mut self, value: ::capnp::text::Reader<'_>) { - self.builder.reborrow().get_pointer_field(2).set_text(value); - } - #[inline] - pub fn init_content(self, size: u32) -> ::capnp::text::Builder<'a> { - self.builder.get_pointer_field(2).init_text(size) - } - #[inline] - pub fn has_content(&self) -> bool { - !self.builder.is_pointer_field_null(2) - } - #[inline] - pub fn get_datetime(self) -> i64 { - self.builder.get_data_field::(0) - } - #[inline] - pub fn set_datetime(&mut self, value: i64) { - self.builder.set_data_field::(0, value); - } - } - - pub struct Pipeline { - _typeless: ::capnp::any_pointer::Pipeline, - } - impl ::capnp::capability::FromTypelessPipeline for Pipeline { - fn new(typeless: ::capnp::any_pointer::Pipeline) -> Self { - Self { - _typeless: typeless, - } - } - } - impl Pipeline {} - mod _private { - pub static ENCODED_NODE: [::capnp::Word; 78] = [ - ::capnp::word(0, 0, 0, 0, 5, 0, 6, 0), - ::capnp::word(50, 25, 14, 89, 91, 12, 143, 231), - ::capnp::word(13, 0, 0, 0, 1, 0, 1, 0), - ::capnp::word(164, 172, 216, 255, 36, 223, 58, 242), - ::capnp::word(3, 0, 7, 0, 0, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(21, 0, 0, 0, 178, 0, 0, 0), - ::capnp::word(29, 0, 0, 0, 7, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(25, 0, 0, 0, 231, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(109, 111, 100, 101, 108, 115, 46, 99), - ::capnp::word(97, 112, 110, 112, 58, 76, 111, 103), - ::capnp::word(69, 118, 101, 110, 116, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 1, 0, 1, 0), - ::capnp::word(16, 0, 0, 0, 3, 0, 4, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(0, 0, 1, 0, 0, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(97, 0, 0, 0, 26, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(92, 0, 0, 0, 3, 0, 1, 0), - ::capnp::word(104, 0, 0, 0, 2, 0, 1, 0), - ::capnp::word(1, 0, 0, 0, 1, 0, 0, 0), - ::capnp::word(0, 0, 1, 0, 1, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(101, 0, 0, 0, 58, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(96, 0, 0, 0, 3, 0, 1, 0), - ::capnp::word(108, 0, 0, 0, 2, 0, 1, 0), - ::capnp::word(2, 0, 0, 0, 2, 0, 0, 0), - ::capnp::word(0, 0, 1, 0, 2, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(105, 0, 0, 0, 66, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(100, 0, 0, 0, 3, 0, 1, 0), - ::capnp::word(112, 0, 0, 0, 2, 0, 1, 0), - ::capnp::word(3, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(0, 0, 1, 0, 3, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(109, 0, 0, 0, 74, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(108, 0, 0, 0, 3, 0, 1, 0), - ::capnp::word(120, 0, 0, 0, 2, 0, 1, 0), - ::capnp::word(105, 100, 0, 0, 0, 0, 0, 0), - ::capnp::word(12, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(12, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(97, 117, 116, 104, 111, 114, 0, 0), - ::capnp::word(12, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(12, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(99, 111, 110, 116, 101, 110, 116, 0), - ::capnp::word(12, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(12, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(100, 97, 116, 101, 116, 105, 109, 101), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(5, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(5, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ]; - pub fn get_field_types(index: u16) -> ::capnp::introspect::Type { - match index { - 0 => <::capnp::text::Owned as ::capnp::introspect::Introspect>::introspect(), - 1 => <::capnp::text::Owned as ::capnp::introspect::Introspect>::introspect(), - 2 => <::capnp::text::Owned as ::capnp::introspect::Introspect>::introspect(), - 3 => ::introspect(), - _ => panic!("invalid field index {}", index), - } - } - pub fn get_annotation_types( - child_index: Option, - index: u32, - ) -> ::capnp::introspect::Type { - panic!("invalid annotation indices ({:?}, {}) ", child_index, index) - } - pub static RAW_SCHEMA: ::capnp::introspect::RawStructSchema = - ::capnp::introspect::RawStructSchema { - encoded_node: &ENCODED_NODE, - nonunion_members: NONUNION_MEMBERS, - members_by_discriminant: MEMBERS_BY_DISCRIMINANT, - }; - pub static NONUNION_MEMBERS: &[u16] = &[0, 1, 2, 3]; - pub static MEMBERS_BY_DISCRIMINANT: &[u16] = &[]; - pub const TYPE_ID: u64 = 0xe78f_0c5b_590e_1932; + pub fn get_annotation_types(child_index: Option, index: u32) -> ::capnp::introspect::Type { + panic!("invalid annotation indices ({:?}, {}) ", child_index, index) } + pub static RAW_SCHEMA: ::capnp::introspect::RawStructSchema = ::capnp::introspect::RawStructSchema { + encoded_node: &ENCODED_NODE, + nonunion_members: NONUNION_MEMBERS, + members_by_discriminant: MEMBERS_BY_DISCRIMINANT, + }; + pub static NONUNION_MEMBERS : &[u16] = &[0,1,2,3]; + pub static MEMBERS_BY_DISCRIMINANT : &[u16] = &[]; + pub const TYPE_ID: u64 = 0xe78f_0c5b_590e_1932; + } } pub mod agent { - #[derive(Copy, Clone)] - pub struct Owned(()); - impl ::capnp::introspect::Introspect for Owned { - fn introspect() -> ::capnp::introspect::Type { - ::capnp::introspect::TypeVariant::Struct(::capnp::introspect::RawBrandedStructSchema { - generic: &_private::RAW_SCHEMA, - field_types: _private::get_field_types, - annotation_types: _private::get_annotation_types, - }) - .into() - } + #[derive(Copy, Clone)] + pub struct Owned(()); + impl ::capnp::introspect::Introspect for Owned { fn introspect() -> ::capnp::introspect::Type { ::capnp::introspect::TypeVariant::Struct(::capnp::introspect::RawBrandedStructSchema { generic: &_private::RAW_SCHEMA, field_types: _private::get_field_types, annotation_types: _private::get_annotation_types }).into() } } + impl ::capnp::traits::Owned for Owned { type Reader<'a> = Reader<'a>; type Builder<'a> = Builder<'a>; } + impl ::capnp::traits::OwnedStruct for Owned { type Reader<'a> = Reader<'a>; type Builder<'a> = Builder<'a>; } + impl ::capnp::traits::Pipelined for Owned { type Pipeline = Pipeline; } + + pub struct Reader<'a> { reader: ::capnp::private::layout::StructReader<'a> } + impl <'a,> ::core::marker::Copy for Reader<'a,> {} + impl <'a,> ::core::clone::Clone for Reader<'a,> { + fn clone(&self) -> Self { *self } + } + + impl <'a,> ::capnp::traits::HasTypeId for Reader<'a,> { + const TYPE_ID: u64 = _private::TYPE_ID; + } + impl <'a,> ::core::convert::From<::capnp::private::layout::StructReader<'a>> for Reader<'a,> { + fn from(reader: ::capnp::private::layout::StructReader<'a>) -> Self { + Self { reader, } } - impl ::capnp::traits::Owned for Owned { - type Reader<'a> = Reader<'a>; - type Builder<'a> = Builder<'a>; + } + + impl <'a,> ::core::convert::From> for ::capnp::dynamic_value::Reader<'a> { + fn from(reader: Reader<'a,>) -> Self { + Self::Struct(::capnp::dynamic_struct::Reader::new(reader.reader, ::capnp::schema::StructSchema::new(::capnp::introspect::RawBrandedStructSchema { generic: &_private::RAW_SCHEMA, field_types: _private::get_field_types::<>, annotation_types: _private::get_annotation_types::<>}))) } - impl ::capnp::traits::OwnedStruct for Owned { - type Reader<'a> = Reader<'a>; - type Builder<'a> = Builder<'a>; + } + + impl <'a,> ::core::fmt::Debug for Reader<'a,> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::result::Result<(), ::core::fmt::Error> { + core::fmt::Debug::fmt(&::core::convert::Into::<::capnp::dynamic_value::Reader<'_>>::into(*self), f) } - impl ::capnp::traits::Pipelined for Owned { - type Pipeline = Pipeline; + } + + 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 { + ::core::result::Result::Ok(reader.get_struct(default)?.into()) + } + } + + 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<'_,> { + Self { .. *self } } - pub struct Reader<'a> { - reader: ::capnp::private::layout::StructReader<'a>, + pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> { + self.reader.total_size() } - impl<'a> ::core::marker::Copy for Reader<'a> {} - impl<'a> ::core::clone::Clone for Reader<'a> { - fn clone(&self) -> Self { - *self - } + #[inline] + pub fn get_name(self) -> ::capnp::Result<::capnp::text::Reader<'a>> { + ::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(0), ::core::option::Option::None) + } + #[inline] + pub fn has_name(&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,> { + const STRUCT_SIZE: ::capnp::private::layout::StructSize = ::capnp::private::layout::StructSize { data: 0, pointers: 1 }; + } + impl <'a,> ::capnp::traits::HasTypeId for Builder<'a,> { + const TYPE_ID: u64 = _private::TYPE_ID; + } + impl <'a,> ::core::convert::From<::capnp::private::layout::StructBuilder<'a>> for Builder<'a,> { + fn from(builder: ::capnp::private::layout::StructBuilder<'a>) -> Self { + Self { builder, } + } + } + + impl <'a,> ::core::convert::From> for ::capnp::dynamic_value::Builder<'a> { + fn from(builder: Builder<'a,>) -> Self { + Self::Struct(::capnp::dynamic_struct::Builder::new(builder.builder, ::capnp::schema::StructSchema::new(::capnp::introspect::RawBrandedStructSchema { generic: &_private::RAW_SCHEMA, field_types: _private::get_field_types::<>, annotation_types: _private::get_annotation_types::<>}))) + } + } + + 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) -> Self { + builder.init_struct(::STRUCT_SIZE).into() + } + fn get_from_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>, default: ::core::option::Option<&'a [::capnp::Word]>) -> ::capnp::Result { + ::core::result::Result::Ok(builder.get_struct(::STRUCT_SIZE, default)?.into()) + } + } + + impl <'a,> ::capnp::traits::SetPointerBuilder for Reader<'a,> { + fn set_pointer_builder(mut pointer: ::capnp::private::layout::PointerBuilder<'_>, value: Self, canonicalize: bool) -> ::capnp::Result<()> { pointer.set_struct(&value.reader, canonicalize) } + } + + impl <'a,> Builder<'a,> { + pub fn into_reader(self) -> Reader<'a,> { + self.builder.into_reader().into() + } + pub fn reborrow(&mut self) -> Builder<'_,> { + Builder { builder: self.builder.reborrow() } + } + pub fn reborrow_as_reader(&self) -> Reader<'_,> { + self.builder.as_reader().into() } - impl<'a> ::capnp::traits::HasTypeId for Reader<'a> { - const TYPE_ID: u64 = _private::TYPE_ID; + pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> { + self.builder.as_reader().total_size() } - impl<'a> ::core::convert::From<::capnp::private::layout::StructReader<'a>> for Reader<'a> { - fn from(reader: ::capnp::private::layout::StructReader<'a>) -> Self { - Self { reader } - } + #[inline] + pub fn get_name(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_name(&mut self, value: ::capnp::text::Reader<'_>) { + self.builder.reborrow().get_pointer_field(0).set_text(value); + } + #[inline] + pub fn init_name(self, size: u32) -> ::capnp::text::Builder<'a> { + self.builder.get_pointer_field(0).init_text(size) + } + #[inline] + pub fn has_name(&self) -> bool { + !self.builder.is_pointer_field_null(0) + } + } - impl<'a> ::core::convert::From> for ::capnp::dynamic_value::Reader<'a> { - fn from(reader: Reader<'a>) -> Self { - Self::Struct(::capnp::dynamic_struct::Reader::new( - reader.reader, - ::capnp::schema::StructSchema::new(::capnp::introspect::RawBrandedStructSchema { - generic: &_private::RAW_SCHEMA, - field_types: _private::get_field_types, - annotation_types: _private::get_annotation_types, - }), - )) - } + pub struct Pipeline { _typeless: ::capnp::any_pointer::Pipeline } + impl ::capnp::capability::FromTypelessPipeline for Pipeline { + fn new(typeless: ::capnp::any_pointer::Pipeline) -> Self { + Self { _typeless: typeless, } } - - impl<'a> ::core::fmt::Debug for Reader<'a> { - fn fmt( - &self, - f: &mut ::core::fmt::Formatter<'_>, - ) -> ::core::result::Result<(), ::core::fmt::Error> { - core::fmt::Debug::fmt( - &::core::convert::Into::<::capnp::dynamic_value::Reader<'_>>::into(*self), - f, - ) - } + } + impl Pipeline { + } + mod _private { + pub static ENCODED_NODE: [::capnp::Word; 32] = [ + ::capnp::word(0, 0, 0, 0, 5, 0, 6, 0), + ::capnp::word(160, 129, 44, 52, 151, 203, 164, 244), + ::capnp::word(13, 0, 0, 0, 1, 0, 0, 0), + ::capnp::word(164, 172, 216, 255, 36, 223, 58, 242), + ::capnp::word(1, 0, 7, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(21, 0, 0, 0, 154, 0, 0, 0), + ::capnp::word(29, 0, 0, 0, 7, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(25, 0, 0, 0, 63, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(109, 111, 100, 101, 108, 115, 46, 99), + ::capnp::word(97, 112, 110, 112, 58, 65, 103, 101), + ::capnp::word(110, 116, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 1, 0, 1, 0), + ::capnp::word(4, 0, 0, 0, 3, 0, 4, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 1, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(13, 0, 0, 0, 42, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(8, 0, 0, 0, 3, 0, 1, 0), + ::capnp::word(20, 0, 0, 0, 2, 0, 1, 0), + ::capnp::word(110, 97, 109, 101, 0, 0, 0, 0), + ::capnp::word(12, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(12, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ]; + pub fn get_field_types(index: u16) -> ::capnp::introspect::Type { + match index { + 0 => <::capnp::text::Owned as ::capnp::introspect::Introspect>::introspect(), + _ => panic!("invalid field index {}", index), + } } - - 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 { - ::core::result::Result::Ok(reader.get_struct(default)?.into()) - } - } - - 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<'_> { - Self { ..*self } - } - - pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> { - self.reader.total_size() - } - #[inline] - pub fn get_name(self) -> ::capnp::Result<::capnp::text::Reader<'a>> { - ::capnp::traits::FromPointerReader::get_from_pointer( - &self.reader.get_pointer_field(0), - ::core::option::Option::None, - ) - } - #[inline] - pub fn has_name(&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> { - const STRUCT_SIZE: ::capnp::private::layout::StructSize = - ::capnp::private::layout::StructSize { - data: 0, - pointers: 1, - }; - } - impl<'a> ::capnp::traits::HasTypeId for Builder<'a> { - const TYPE_ID: u64 = _private::TYPE_ID; - } - impl<'a> ::core::convert::From<::capnp::private::layout::StructBuilder<'a>> for Builder<'a> { - fn from(builder: ::capnp::private::layout::StructBuilder<'a>) -> Self { - Self { builder } - } - } - - impl<'a> ::core::convert::From> for ::capnp::dynamic_value::Builder<'a> { - fn from(builder: Builder<'a>) -> Self { - Self::Struct(::capnp::dynamic_struct::Builder::new( - builder.builder, - ::capnp::schema::StructSchema::new(::capnp::introspect::RawBrandedStructSchema { - generic: &_private::RAW_SCHEMA, - field_types: _private::get_field_types, - annotation_types: _private::get_annotation_types, - }), - )) - } - } - - 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) -> Self { - builder - .init_struct(::STRUCT_SIZE) - .into() - } - fn get_from_pointer( - builder: ::capnp::private::layout::PointerBuilder<'a>, - default: ::core::option::Option<&'a [::capnp::Word]>, - ) -> ::capnp::Result { - ::core::result::Result::Ok( - builder - .get_struct( - ::STRUCT_SIZE, - default, - )? - .into(), - ) - } - } - - impl<'a> ::capnp::traits::SetPointerBuilder for Reader<'a> { - fn set_pointer_builder( - mut pointer: ::capnp::private::layout::PointerBuilder<'_>, - value: Self, - canonicalize: bool, - ) -> ::capnp::Result<()> { - pointer.set_struct(&value.reader, canonicalize) - } - } - - impl<'a> Builder<'a> { - pub fn into_reader(self) -> Reader<'a> { - self.builder.into_reader().into() - } - pub fn reborrow(&mut self) -> Builder<'_> { - Builder { - builder: self.builder.reborrow(), - } - } - pub fn reborrow_as_reader(&self) -> Reader<'_> { - self.builder.as_reader().into() - } - - pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> { - self.builder.as_reader().total_size() - } - #[inline] - pub fn get_name(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_name(&mut self, value: ::capnp::text::Reader<'_>) { - self.builder.reborrow().get_pointer_field(0).set_text(value); - } - #[inline] - pub fn init_name(self, size: u32) -> ::capnp::text::Builder<'a> { - self.builder.get_pointer_field(0).init_text(size) - } - #[inline] - pub fn has_name(&self) -> bool { - !self.builder.is_pointer_field_null(0) - } - } - - pub struct Pipeline { - _typeless: ::capnp::any_pointer::Pipeline, - } - impl ::capnp::capability::FromTypelessPipeline for Pipeline { - fn new(typeless: ::capnp::any_pointer::Pipeline) -> Self { - Self { - _typeless: typeless, - } - } - } - impl Pipeline {} - mod _private { - pub static ENCODED_NODE: [::capnp::Word; 32] = [ - ::capnp::word(0, 0, 0, 0, 5, 0, 6, 0), - ::capnp::word(160, 129, 44, 52, 151, 203, 164, 244), - ::capnp::word(13, 0, 0, 0, 1, 0, 0, 0), - ::capnp::word(164, 172, 216, 255, 36, 223, 58, 242), - ::capnp::word(1, 0, 7, 0, 0, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(21, 0, 0, 0, 154, 0, 0, 0), - ::capnp::word(29, 0, 0, 0, 7, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(25, 0, 0, 0, 63, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(109, 111, 100, 101, 108, 115, 46, 99), - ::capnp::word(97, 112, 110, 112, 58, 65, 103, 101), - ::capnp::word(110, 116, 0, 0, 0, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 1, 0, 1, 0), - ::capnp::word(4, 0, 0, 0, 3, 0, 4, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(0, 0, 1, 0, 0, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(13, 0, 0, 0, 42, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(8, 0, 0, 0, 3, 0, 1, 0), - ::capnp::word(20, 0, 0, 0, 2, 0, 1, 0), - ::capnp::word(110, 97, 109, 101, 0, 0, 0, 0), - ::capnp::word(12, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(12, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), - ]; - pub fn get_field_types(index: u16) -> ::capnp::introspect::Type { - match index { - 0 => <::capnp::text::Owned as ::capnp::introspect::Introspect>::introspect(), - _ => panic!("invalid field index {}", index), - } - } - pub fn get_annotation_types( - child_index: Option, - index: u32, - ) -> ::capnp::introspect::Type { - panic!("invalid annotation indices ({:?}, {}) ", child_index, index) - } - pub static RAW_SCHEMA: ::capnp::introspect::RawStructSchema = - ::capnp::introspect::RawStructSchema { - encoded_node: &ENCODED_NODE, - nonunion_members: NONUNION_MEMBERS, - members_by_discriminant: MEMBERS_BY_DISCRIMINANT, - }; - pub static NONUNION_MEMBERS: &[u16] = &[0]; - pub static MEMBERS_BY_DISCRIMINANT: &[u16] = &[]; - pub const TYPE_ID: u64 = 0xf4a4_cb97_342c_81a0; + pub fn get_annotation_types(child_index: Option, index: u32) -> ::capnp::introspect::Type { + panic!("invalid annotation indices ({:?}, {}) ", child_index, index) } + pub static RAW_SCHEMA: ::capnp::introspect::RawStructSchema = ::capnp::introspect::RawStructSchema { + encoded_node: &ENCODED_NODE, + nonunion_members: NONUNION_MEMBERS, + members_by_discriminant: MEMBERS_BY_DISCRIMINANT, + }; + pub static NONUNION_MEMBERS : &[u16] = &[0]; + pub static MEMBERS_BY_DISCRIMINANT : &[u16] = &[]; + pub const TYPE_ID: u64 = 0xf4a4_cb97_342c_81a0; + } +} + +pub mod lease { + #[derive(Copy, Clone)] + pub struct Owned(()); + impl ::capnp::introspect::Introspect for Owned { fn introspect() -> ::capnp::introspect::Type { ::capnp::introspect::TypeVariant::Struct(::capnp::introspect::RawBrandedStructSchema { generic: &_private::RAW_SCHEMA, field_types: _private::get_field_types, annotation_types: _private::get_annotation_types }).into() } } + impl ::capnp::traits::Owned for Owned { type Reader<'a> = Reader<'a>; type Builder<'a> = Builder<'a>; } + impl ::capnp::traits::OwnedStruct for Owned { type Reader<'a> = Reader<'a>; type Builder<'a> = Builder<'a>; } + impl ::capnp::traits::Pipelined for Owned { type Pipeline = Pipeline; } + + pub struct Reader<'a> { reader: ::capnp::private::layout::StructReader<'a> } + impl <'a,> ::core::marker::Copy for Reader<'a,> {} + impl <'a,> ::core::clone::Clone for Reader<'a,> { + fn clone(&self) -> Self { *self } + } + + impl <'a,> ::capnp::traits::HasTypeId for Reader<'a,> { + const TYPE_ID: u64 = _private::TYPE_ID; + } + impl <'a,> ::core::convert::From<::capnp::private::layout::StructReader<'a>> for Reader<'a,> { + fn from(reader: ::capnp::private::layout::StructReader<'a>) -> Self { + Self { reader, } + } + } + + impl <'a,> ::core::convert::From> for ::capnp::dynamic_value::Reader<'a> { + fn from(reader: Reader<'a,>) -> Self { + Self::Struct(::capnp::dynamic_struct::Reader::new(reader.reader, ::capnp::schema::StructSchema::new(::capnp::introspect::RawBrandedStructSchema { generic: &_private::RAW_SCHEMA, field_types: _private::get_field_types::<>, annotation_types: _private::get_annotation_types::<>}))) + } + } + + impl <'a,> ::core::fmt::Debug for Reader<'a,> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::result::Result<(), ::core::fmt::Error> { + core::fmt::Debug::fmt(&::core::convert::Into::<::capnp::dynamic_value::Reader<'_>>::into(*self), f) + } + } + + 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 { + ::core::result::Result::Ok(reader.get_struct(default)?.into()) + } + } + + 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<'_,> { + Self { .. *self } + } + + pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> { + self.reader.total_size() + } + #[inline] + pub fn get_id(self) -> ::capnp::Result<::capnp::text::Reader<'a>> { + ::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(0), ::core::option::Option::None) + } + #[inline] + pub fn has_id(&self) -> bool { + !self.reader.get_pointer_field(0).is_null() + } + #[inline] + pub fn get_lease(self) -> ::capnp::Result<::capnp::text::Reader<'a>> { + ::capnp::traits::FromPointerReader::get_from_pointer(&self.reader.get_pointer_field(1), ::core::option::Option::None) + } + #[inline] + pub fn has_lease(&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,> { + const STRUCT_SIZE: ::capnp::private::layout::StructSize = ::capnp::private::layout::StructSize { data: 0, pointers: 2 }; + } + impl <'a,> ::capnp::traits::HasTypeId for Builder<'a,> { + const TYPE_ID: u64 = _private::TYPE_ID; + } + impl <'a,> ::core::convert::From<::capnp::private::layout::StructBuilder<'a>> for Builder<'a,> { + fn from(builder: ::capnp::private::layout::StructBuilder<'a>) -> Self { + Self { builder, } + } + } + + impl <'a,> ::core::convert::From> for ::capnp::dynamic_value::Builder<'a> { + fn from(builder: Builder<'a,>) -> Self { + Self::Struct(::capnp::dynamic_struct::Builder::new(builder.builder, ::capnp::schema::StructSchema::new(::capnp::introspect::RawBrandedStructSchema { generic: &_private::RAW_SCHEMA, field_types: _private::get_field_types::<>, annotation_types: _private::get_annotation_types::<>}))) + } + } + + 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) -> Self { + builder.init_struct(::STRUCT_SIZE).into() + } + fn get_from_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>, default: ::core::option::Option<&'a [::capnp::Word]>) -> ::capnp::Result { + ::core::result::Result::Ok(builder.get_struct(::STRUCT_SIZE, default)?.into()) + } + } + + impl <'a,> ::capnp::traits::SetPointerBuilder for Reader<'a,> { + fn set_pointer_builder(mut pointer: ::capnp::private::layout::PointerBuilder<'_>, value: Self, canonicalize: bool) -> ::capnp::Result<()> { pointer.set_struct(&value.reader, canonicalize) } + } + + impl <'a,> Builder<'a,> { + pub fn into_reader(self) -> Reader<'a,> { + self.builder.into_reader().into() + } + pub fn reborrow(&mut self) -> Builder<'_,> { + Builder { builder: self.builder.reborrow() } + } + pub fn reborrow_as_reader(&self) -> Reader<'_,> { + self.builder.as_reader().into() + } + + pub fn total_size(&self) -> ::capnp::Result<::capnp::MessageSize> { + self.builder.as_reader().total_size() + } + #[inline] + pub fn get_id(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_id(&mut self, value: ::capnp::text::Reader<'_>) { + self.builder.reborrow().get_pointer_field(0).set_text(value); + } + #[inline] + pub fn init_id(self, size: u32) -> ::capnp::text::Builder<'a> { + self.builder.get_pointer_field(0).init_text(size) + } + #[inline] + pub fn has_id(&self) -> bool { + !self.builder.is_pointer_field_null(0) + } + #[inline] + pub fn get_lease(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_lease(&mut self, value: ::capnp::text::Reader<'_>) { + self.builder.reborrow().get_pointer_field(1).set_text(value); + } + #[inline] + pub fn init_lease(self, size: u32) -> ::capnp::text::Builder<'a> { + self.builder.get_pointer_field(1).init_text(size) + } + #[inline] + pub fn has_lease(&self) -> bool { + !self.builder.is_pointer_field_null(1) + } + } + + pub struct Pipeline { _typeless: ::capnp::any_pointer::Pipeline } + impl ::capnp::capability::FromTypelessPipeline for Pipeline { + fn new(typeless: ::capnp::any_pointer::Pipeline) -> Self { + Self { _typeless: typeless, } + } + } + impl Pipeline { + } + mod _private { + pub static ENCODED_NODE: [::capnp::Word; 47] = [ + ::capnp::word(0, 0, 0, 0, 5, 0, 6, 0), + ::capnp::word(98, 86, 14, 197, 84, 8, 214, 176), + ::capnp::word(13, 0, 0, 0, 1, 0, 0, 0), + ::capnp::word(164, 172, 216, 255, 36, 223, 58, 242), + ::capnp::word(2, 0, 7, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(21, 0, 0, 0, 154, 0, 0, 0), + ::capnp::word(29, 0, 0, 0, 7, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(25, 0, 0, 0, 119, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(109, 111, 100, 101, 108, 115, 46, 99), + ::capnp::word(97, 112, 110, 112, 58, 76, 101, 97), + ::capnp::word(115, 101, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 1, 0, 1, 0), + ::capnp::word(8, 0, 0, 0, 3, 0, 4, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 1, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(41, 0, 0, 0, 26, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(36, 0, 0, 0, 3, 0, 1, 0), + ::capnp::word(48, 0, 0, 0, 2, 0, 1, 0), + ::capnp::word(1, 0, 0, 0, 1, 0, 0, 0), + ::capnp::word(0, 0, 1, 0, 1, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(45, 0, 0, 0, 50, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(40, 0, 0, 0, 3, 0, 1, 0), + ::capnp::word(52, 0, 0, 0, 2, 0, 1, 0), + ::capnp::word(105, 100, 0, 0, 0, 0, 0, 0), + ::capnp::word(12, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(12, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(108, 101, 97, 115, 101, 0, 0, 0), + ::capnp::word(12, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(12, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ::capnp::word(0, 0, 0, 0, 0, 0, 0, 0), + ]; + pub fn get_field_types(index: u16) -> ::capnp::introspect::Type { + match index { + 0 => <::capnp::text::Owned as ::capnp::introspect::Introspect>::introspect(), + 1 => <::capnp::text::Owned as ::capnp::introspect::Introspect>::introspect(), + _ => panic!("invalid field index {}", index), + } + } + pub fn get_annotation_types(child_index: Option, index: u32) -> ::capnp::introspect::Type { + panic!("invalid annotation indices ({:?}, {}) ", child_index, index) + } + pub static RAW_SCHEMA: ::capnp::introspect::RawStructSchema = ::capnp::introspect::RawStructSchema { + encoded_node: &ENCODED_NODE, + nonunion_members: NONUNION_MEMBERS, + members_by_discriminant: MEMBERS_BY_DISCRIMINANT, + }; + pub static NONUNION_MEMBERS : &[u16] = &[0,1]; + pub static MEMBERS_BY_DISCRIMINANT : &[u16] = &[]; + pub const TYPE_ID: u64 = 0xb0d6_0854_c50e_5662; + } } diff --git a/crates/churn-domain/src/lib.rs b/crates/churn-domain/src/lib.rs index 8f2ca8a..2934c03 100644 --- a/crates/churn-domain/src/lib.rs +++ b/crates/churn-domain/src/lib.rs @@ -47,3 +47,9 @@ impl LogEvent { pub struct Agent { pub name: String, } + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct Lease { + pub id: uuid::Uuid, + pub lease: uuid::Uuid, +} diff --git a/crates/churn-server/src/agent.rs b/crates/churn-server/src/agent.rs index e9c5c82..5d47be9 100644 --- a/crates/churn-server/src/agent.rs +++ b/crates/churn-server/src/agent.rs @@ -24,13 +24,6 @@ impl std::ops::Deref for AgentService { } } -impl Default for AgentService { - fn default() -> Self { - Self(Arc::new(DefaultAgentService::default())) - } -} - -#[derive(Default)] struct DefaultAgentService { agents: Db, } diff --git a/crates/churn-server/src/db.rs b/crates/churn-server/src/db.rs index 7c7a865..c0bbf4b 100644 --- a/crates/churn-server/src/db.rs +++ b/crates/churn-server/src/db.rs @@ -1,6 +1,6 @@ use core::slice::SlicePattern; -use std::path::{Path, PathBuf}; +use std::path::{Path}; use std::sync::Arc; use async_trait::async_trait; @@ -22,22 +22,10 @@ impl std::ops::Deref for Db { } } -impl Default for Db { - fn default() -> Self { - Self(Arc::new(DefaultDb::default())) - } -} - struct DefaultDb { db: sled::Db, } -impl Default for DefaultDb { - fn default() -> Self { - Self::new(&PathBuf::from("churn-server.sled")) - } -} - impl DefaultDb { pub fn new(path: &Path) -> Self { Self { diff --git a/crates/churn-server/src/event.rs b/crates/churn-server/src/event.rs index b974cbe..9ee7f0a 100644 --- a/crates/churn-server/src/event.rs +++ b/crates/churn-server/src/event.rs @@ -26,13 +26,6 @@ impl std::ops::Deref for EventService { } } -impl Default for EventService { - fn default() -> Self { - Self(Arc::new(DefaultEventService::default())) - } -} - -#[derive(Default)] struct DefaultEventService { db: Db, } @@ -84,6 +77,7 @@ impl EventServiceTrait for DefaultEventService { let events = events .iter() + .map(|x| x.as_slice()) .flat_map(LogEvent::deserialize_capnp) .sorted_by_key(|i| i.timestamp) .collect(); diff --git a/crates/churn-server/src/lease.rs b/crates/churn-server/src/lease.rs index e29a3eb..a860106 100644 --- a/crates/churn-server/src/lease.rs +++ b/crates/churn-server/src/lease.rs @@ -2,11 +2,21 @@ use std::sync::Arc; use axum::async_trait; -use tokio::sync::Mutex; +use churn_capnp::CapnpPackExt; +use churn_domain::Lease; + + +use crate::db::Db; #[derive(Clone)] pub struct LeaseService(Arc); +impl LeaseService { + pub fn new(db: Db) -> Self { + Self(Arc::new(DefaultLeaseService::new(db))) + } +} + impl std::ops::Deref for LeaseService { type Target = Arc; @@ -15,15 +25,14 @@ impl std::ops::Deref for LeaseService { } } -impl Default for LeaseService { - fn default() -> Self { - Self(Arc::new(DefaultLeaseService::default())) - } +struct DefaultLeaseService { + db: Db, } -#[derive(Default)] -struct DefaultLeaseService { - leases: Arc>>, +impl DefaultLeaseService { + pub fn new(db: Db) -> Self { + Self { db } + } } #[async_trait] @@ -34,12 +43,17 @@ pub trait LeaseServiceTrait { #[async_trait] impl LeaseServiceTrait for DefaultLeaseService { async fn create_lease(&self) -> anyhow::Result { - let mut leases = self.leases.lock().await; + let lease = uuid::Uuid::new_v4(); + let id = uuid::Uuid::new_v4(); - let lease = uuid::Uuid::new_v4().to_string(); + self.db + .insert( + "lease", + &lease.to_string(), + &Lease { id, lease }.serialize_capnp(), + ) + .await?; - leases.push(lease.clone()); - - Ok(lease) + Ok(lease.to_string()) } } diff --git a/crates/churn-server/src/main.rs b/crates/churn-server/src/main.rs index 6a6ea51..7d73d69 100644 --- a/crates/churn-server/src/main.rs +++ b/crates/churn-server/src/main.rs @@ -70,37 +70,34 @@ async fn main() -> anyhow::Result<()> { let cli = Command::parse(); - match cli.command { - Some(Commands::Serve { host }) => { - tracing::info!("Starting churn server"); - let db = match cli.global.database { - DatabaseType::Sled => Db::new_sled(&cli.global.sled_path), - }; + if let Some(Commands::Serve { host }) = cli.command { + tracing::info!("Starting churn server"); + let db = match cli.global.database { + DatabaseType::Sled => Db::new_sled(&cli.global.sled_path), + }; - let app = Router::new() - .route("/ping", get(ping)) - .route("/logs", get(logs)) - .nest( - "/agent", - Router::new() - .route("/enroll", post(enroll)) - .route("/ping", post(agent_ping)) - .route("/events", post(get_tasks)) - .route("/lease", post(agent_lease)), - ) - .with_state(AppState { - agent: AgentService::new(db.clone()), - leases: LeaseService::default(), - events: EventService::new(db.clone()), - }); + let app = Router::new() + .route("/ping", get(ping)) + .route("/logs", get(logs)) + .nest( + "/agent", + Router::new() + .route("/enroll", post(enroll)) + .route("/ping", post(agent_ping)) + .route("/events", post(get_tasks)) + .route("/lease", post(agent_lease)), + ) + .with_state(AppState { + agent: AgentService::new(db.clone()), + leases: LeaseService::new(db.clone()), + events: EventService::new(db.clone()), + }); - tracing::info!("churn server listening on {}", host); - axum::Server::bind(&host) - .serve(app.into_make_service()) - .await - .unwrap(); - } - None => {} + tracing::info!("churn server listening on {}", host); + axum::Server::bind(&host) + .serve(app.into_make_service()) + .await + .unwrap(); } Ok(()) @@ -231,10 +228,10 @@ async fn logs( .await .map_err(AppError::Internal)?; - return Ok(Json(ServerMonitorResp { + Ok(Json(ServerMonitorResp { cursor: Some(cursor), logs: Vec::new(), - })); + })) } } } diff --git a/crates/churning/src/main.rs b/crates/churning/src/main.rs index b69c4cd..ef96a29 100644 --- a/crates/churning/src/main.rs +++ b/crates/churning/src/main.rs @@ -1,13 +1,13 @@ use std::{path::PathBuf, sync::Arc}; use dagger_rust::build::{RustVersion, SlimImage}; -use dagger_sdk::{Config, Query}; +use dagger_sdk::Query; use tokio::io::{AsyncBufReadExt, AsyncWriteExt}; #[tokio::main] async fn main() -> eyre::Result<()> { - let mut config = Config::default(); - config.logger = None; + // let mut config = Config::default(); + // config.logger = None; println!("Building churning...");