Skip to content

Commit

Permalink
Add field::PtrValue trait to generalize pointer types.
Browse files Browse the repository at this point in the history
This is necessary for generated generic pointers and simplifying pointer field info.
  • Loading branch information
ObsidianMinor committed Aug 4, 2024
1 parent f8c680c commit d5fc26e
Show file tree
Hide file tree
Showing 12 changed files with 253 additions and 199 deletions.
80 changes: 38 additions & 42 deletions recapn-rpc/src/gen/capnp/rpc.capnp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl Message {
},
field: _p::Descriptor::<_p::Struct<Message>> {
slot: 0u32,
default: _p::StructReader::empty(),
default: None,
},
};
const ABORT: _p::VariantDescriptor<_p::Struct<Exception>> = _p::VariantDescriptor::<
Expand All @@ -117,7 +117,7 @@ impl Message {
},
field: _p::Descriptor::<_p::Struct<Exception>> {
slot: 0u32,
default: _p::StructReader::empty(),
default: None,
},
};
const CALL: _p::VariantDescriptor<_p::Struct<Call>> = _p::VariantDescriptor::<
Expand All @@ -129,7 +129,7 @@ impl Message {
},
field: _p::Descriptor::<_p::Struct<Call>> {
slot: 0u32,
default: _p::StructReader::empty(),
default: None,
},
};
const RETURN: _p::VariantDescriptor<_p::Struct<Return>> = _p::VariantDescriptor::<
Expand All @@ -141,7 +141,7 @@ impl Message {
},
field: _p::Descriptor::<_p::Struct<Return>> {
slot: 0u32,
default: _p::StructReader::empty(),
default: None,
},
};
const FINISH: _p::VariantDescriptor<_p::Struct<Finish>> = _p::VariantDescriptor::<
Expand All @@ -153,7 +153,7 @@ impl Message {
},
field: _p::Descriptor::<_p::Struct<Finish>> {
slot: 0u32,
default: _p::StructReader::empty(),
default: None,
},
};
const RESOLVE: _p::VariantDescriptor<_p::Struct<Resolve>> = _p::VariantDescriptor::<
Expand All @@ -165,7 +165,7 @@ impl Message {
},
field: _p::Descriptor::<_p::Struct<Resolve>> {
slot: 0u32,
default: _p::StructReader::empty(),
default: None,
},
};
const RELEASE: _p::VariantDescriptor<_p::Struct<Release>> = _p::VariantDescriptor::<
Expand All @@ -177,7 +177,7 @@ impl Message {
},
field: _p::Descriptor::<_p::Struct<Release>> {
slot: 0u32,
default: _p::StructReader::empty(),
default: None,
},
};
const OBSOLETE_SAVE: _p::VariantDescriptor<_p::AnyPtr> = _p::VariantDescriptor::<
Expand All @@ -189,7 +189,7 @@ impl Message {
},
field: _p::Descriptor::<_p::AnyPtr> {
slot: 0u32,
default: _p::ptr::PtrReader::null(),
default: None,
},
};
const BOOTSTRAP: _p::VariantDescriptor<_p::Struct<Bootstrap>> = _p::VariantDescriptor::<
Expand All @@ -201,7 +201,7 @@ impl Message {
},
field: _p::Descriptor::<_p::Struct<Bootstrap>> {
slot: 0u32,
default: _p::StructReader::empty(),
default: None,
},
};
const OBSOLETE_DELETE: _p::VariantDescriptor<_p::AnyPtr> = _p::VariantDescriptor::<
Expand All @@ -213,7 +213,7 @@ impl Message {
},
field: _p::Descriptor::<_p::AnyPtr> {
slot: 0u32,
default: _p::ptr::PtrReader::null(),
default: None,
},
};
const PROVIDE: _p::VariantDescriptor<_p::Struct<Provide>> = _p::VariantDescriptor::<
Expand All @@ -225,7 +225,7 @@ impl Message {
},
field: _p::Descriptor::<_p::Struct<Provide>> {
slot: 0u32,
default: _p::StructReader::empty(),
default: None,
},
};
const ACCEPT: _p::VariantDescriptor<_p::Struct<Accept>> = _p::VariantDescriptor::<
Expand All @@ -237,7 +237,7 @@ impl Message {
},
field: _p::Descriptor::<_p::Struct<Accept>> {
slot: 0u32,
default: _p::StructReader::empty(),
default: None,
},
};
const JOIN: _p::VariantDescriptor<_p::Struct<Join>> = _p::VariantDescriptor::<
Expand All @@ -249,7 +249,7 @@ impl Message {
},
field: _p::Descriptor::<_p::Struct<Join>> {
slot: 0u32,
default: _p::StructReader::empty(),
default: None,
},
};
const DISEMBARGO: _p::VariantDescriptor<_p::Struct<Disembargo>> = _p::VariantDescriptor::<
Expand All @@ -261,7 +261,7 @@ impl Message {
},
field: _p::Descriptor::<_p::Struct<Disembargo>> {
slot: 0u32,
default: _p::StructReader::empty(),
default: None,
},
};
}
Expand Down Expand Up @@ -1084,7 +1084,7 @@ impl Bootstrap {
_p::AnyPtr,
> {
slot: 0u32,
default: _p::ptr::PtrReader::null(),
default: None,
};
}
impl<'p, T: _p::rpc::Table + 'p> bootstrap::Reader<'p, T> {
Expand Down Expand Up @@ -1240,7 +1240,7 @@ impl Call {
_p::Struct<MessageTarget>,
> {
slot: 0u32,
default: _p::StructReader::empty(),
default: None,
};
const INTERFACE_ID: _p::Descriptor<u64> = _p::Descriptor::<u64> {
slot: 1u32,
Expand All @@ -1254,7 +1254,7 @@ impl Call {
_p::Struct<Payload>,
> {
slot: 1u32,
default: _p::StructReader::empty(),
default: None,
};
const SEND_RESULTS_TO: _p::Descriptor<_p::Group<call::SendResultsTo>> = ();
const ALLOW_THIRD_PARTY_TAIL_CALL: _p::Descriptor<bool> = _p::Descriptor::<bool> {
Expand Down Expand Up @@ -1560,7 +1560,7 @@ pub mod call {
},
field: _p::Descriptor::<_p::AnyPtr> {
slot: 2u32,
default: _p::ptr::PtrReader::null(),
default: None,
},
};
}
Expand Down Expand Up @@ -1850,7 +1850,7 @@ impl Return {
},
field: _p::Descriptor::<_p::Struct<Payload>> {
slot: 0u32,
default: _p::StructReader::empty(),
default: None,
},
};
const EXCEPTION: _p::VariantDescriptor<_p::Struct<Exception>> = _p::VariantDescriptor::<
Expand All @@ -1862,7 +1862,7 @@ impl Return {
},
field: _p::Descriptor::<_p::Struct<Exception>> {
slot: 0u32,
default: _p::StructReader::empty(),
default: None,
},
};
const CANCELED: _p::VariantDescriptor<()> = _p::VariantDescriptor::<()> {
Expand Down Expand Up @@ -1902,7 +1902,7 @@ impl Return {
},
field: _p::Descriptor::<_p::AnyPtr> {
slot: 0u32,
default: _p::ptr::PtrReader::null(),
default: None,
},
};
}
Expand Down Expand Up @@ -2491,7 +2491,7 @@ impl Resolve {
},
field: _p::Descriptor::<_p::Struct<CapDescriptor>> {
slot: 0u32,
default: _p::StructReader::empty(),
default: None,
},
};
const EXCEPTION: _p::VariantDescriptor<_p::Struct<Exception>> = _p::VariantDescriptor::<
Expand All @@ -2503,7 +2503,7 @@ impl Resolve {
},
field: _p::Descriptor::<_p::Struct<Exception>> {
slot: 0u32,
default: _p::StructReader::empty(),
default: None,
},
};
}
Expand Down Expand Up @@ -2890,7 +2890,7 @@ impl Disembargo {
_p::Struct<MessageTarget>,
> {
slot: 0u32,
default: _p::StructReader::empty(),
default: None,
};
const CONTEXT: _p::Descriptor<_p::Group<disembargo::Context>> = ();
}
Expand Down Expand Up @@ -3387,11 +3387,11 @@ impl Provide {
_p::Struct<MessageTarget>,
> {
slot: 0u32,
default: _p::StructReader::empty(),
default: None,
};
const RECIPIENT: _p::Descriptor<_p::AnyPtr> = _p::Descriptor::<_p::AnyPtr> {
slot: 1u32,
default: _p::ptr::PtrReader::null(),
default: None,
};
}
impl<'p, T: _p::rpc::Table + 'p> provide::Reader<'p, T> {
Expand Down Expand Up @@ -3561,7 +3561,7 @@ impl Accept {
};
const PROVISION: _p::Descriptor<_p::AnyPtr> = _p::Descriptor::<_p::AnyPtr> {
slot: 0u32,
default: _p::ptr::PtrReader::null(),
default: None,
};
const EMBARGO: _p::Descriptor<bool> = _p::Descriptor::<bool> {
slot: 32u32,
Expand Down Expand Up @@ -3721,11 +3721,11 @@ impl Join {
_p::Struct<MessageTarget>,
> {
slot: 0u32,
default: _p::StructReader::empty(),
default: None,
};
const KEY_PART: _p::Descriptor<_p::AnyPtr> = _p::Descriptor::<_p::AnyPtr> {
slot: 1u32,
default: _p::ptr::PtrReader::null(),
default: None,
};
}
impl<'p, T: _p::rpc::Table + 'p> join::Reader<'p, T> {
Expand Down Expand Up @@ -3903,7 +3903,7 @@ impl MessageTarget {
},
field: _p::Descriptor::<_p::Struct<PromisedAnswer>> {
slot: 0u32,
default: _p::StructReader::empty(),
default: None,
},
};
}
Expand Down Expand Up @@ -4142,15 +4142,13 @@ impl _p::ty::Struct for Payload {
impl Payload {
const CONTENT: _p::Descriptor<_p::AnyPtr> = _p::Descriptor::<_p::AnyPtr> {
slot: 0u32,
default: _p::ptr::PtrReader::null(),
default: None,
};
const CAP_TABLE: _p::Descriptor<_p::List<_p::Struct<CapDescriptor>>> = _p::Descriptor::<
_p::List<_p::Struct<CapDescriptor>>,
> {
slot: 1u32,
default: _p::ListReader::empty(
_p::ElementSize::size_of::<_p::Struct<CapDescriptor>>(),
),
default: None,
};
}
impl<'p, T: _p::rpc::Table + 'p> payload::Reader<'p, T> {
Expand Down Expand Up @@ -4358,7 +4356,7 @@ impl CapDescriptor {
},
field: _p::Descriptor::<_p::Struct<PromisedAnswer>> {
slot: 0u32,
default: _p::StructReader::empty(),
default: None,
},
};
const THIRD_PARTY_HOSTED: _p::VariantDescriptor<
Expand All @@ -4370,7 +4368,7 @@ impl CapDescriptor {
},
field: _p::Descriptor::<_p::Struct<ThirdPartyCapDescriptor>> {
slot: 0u32,
default: _p::StructReader::empty(),
default: None,
},
};
}
Expand Down Expand Up @@ -4806,9 +4804,7 @@ impl PromisedAnswer {
_p::List<_p::Struct<promised_answer::Op>>,
> {
slot: 0u32,
default: _p::ListReader::empty(
_p::ElementSize::size_of::<_p::Struct<promised_answer::Op>>(),
),
default: None,
};
}
impl<'p, T: _p::rpc::Table + 'p> promised_answer::Reader<'p, T> {
Expand Down Expand Up @@ -5205,7 +5201,7 @@ impl _p::ty::Struct for ThirdPartyCapDescriptor {
impl ThirdPartyCapDescriptor {
const ID: _p::Descriptor<_p::AnyPtr> = _p::Descriptor::<_p::AnyPtr> {
slot: 0u32,
default: _p::ptr::PtrReader::null(),
default: None,
};
const VINE_ID: _p::Descriptor<u32> = _p::Descriptor::<u32> {
slot: 0u32,
Expand Down Expand Up @@ -5367,7 +5363,7 @@ impl _p::ty::Struct for Exception {
impl Exception {
const REASON: _p::Descriptor<_p::Text> = _p::Descriptor::<_p::Text> {
slot: 0u32,
default: _p::text::Reader::empty(),
default: None,
};
const OBSOLETE_IS_CALLERS_FAULT: _p::Descriptor<bool> = _p::Descriptor::<bool> {
slot: 0u32,
Expand All @@ -5385,7 +5381,7 @@ impl Exception {
};
const TRACE: _p::Descriptor<_p::Text> = _p::Descriptor::<_p::Text> {
slot: 1u32,
default: _p::text::Reader::empty(),
default: None,
};
}
impl<'p, T: _p::rpc::Table + 'p> exception::Reader<'p, T> {
Expand Down
11 changes: 0 additions & 11 deletions recapn/src/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@ impl<T> IntoFamily for AnyPtr<T> {
type Family = AnyPtr;
}

impl ty::Value for AnyPtr {
type Default = ptr::PtrReader<'static, Empty>;
}

impl ty::ListValue for AnyPtr {
const ELEMENT_SIZE: list::ElementSize = list::ElementSize::Pointer;
}
Expand Down Expand Up @@ -583,10 +579,6 @@ impl<T> IntoFamily for AnyStruct<T> {
type Family = AnyStruct;
}

impl ty::Value for AnyStruct {
type Default = ptr::StructReader<'static, Empty>;
}

impl ty::DynListValue for AnyStruct {
const PTR_ELEMENT_SIZE: crate::ptr::PtrElementSize = crate::ptr::PtrElementSize::InlineComposite;
}
Expand Down Expand Up @@ -900,9 +892,6 @@ impl<T> IntoFamily for AnyList<T> {
type Family = AnyList;
}

impl ty::Value for AnyList {
type Default = ptr::ListReader<'static, Empty>;
}
impl ty::ListValue for AnyList {
const ELEMENT_SIZE: list::ElementSize = list::ElementSize::Pointer;
}
Expand Down
3 changes: 0 additions & 3 deletions recapn/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ impl Sealed for Data {}
impl<T> IntoFamily for Data<T> {
type Family = Data;
}
impl ty::Value for Data {
type Default = Reader<'static>;
}
impl ty::ListValue for Data {
const ELEMENT_SIZE: ElementSize = ElementSize::Pointer;
}
Expand Down
Loading

0 comments on commit d5fc26e

Please sign in to comment.