Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove 'IntoInternalStructReader' trait #351

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 60 additions & 60 deletions capnp-rpc/src/rpc_capnp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ pub mod message {
}
}

impl <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> {
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
self.reader
impl <'a,> From<Reader<'a,>> for ::capnp::private::layout::StructReader<'a> {
fn from(reader: Reader<'a,>) -> ::capnp::private::layout::StructReader<'a> {
reader.reader
}
}

Expand Down Expand Up @@ -582,9 +582,9 @@ pub mod bootstrap {
}
}

impl <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> {
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
self.reader
impl <'a,> From<Reader<'a,>> for ::capnp::private::layout::StructReader<'a> {
fn from(reader: Reader<'a,>) -> ::capnp::private::layout::StructReader<'a> {
reader.reader
}
}

Expand Down Expand Up @@ -727,9 +727,9 @@ pub mod call {
}
}

impl <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> {
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
self.reader
impl <'a,> From<Reader<'a,>> for ::capnp::private::layout::StructReader<'a> {
fn from(reader: Reader<'a,>) -> ::capnp::private::layout::StructReader<'a> {
reader.reader
}
}

Expand Down Expand Up @@ -955,9 +955,9 @@ pub mod call {
}
}

impl <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> {
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
self.reader
impl <'a,> From<Reader<'a,>> for ::capnp::private::layout::StructReader<'a> {
fn from(reader: Reader<'a,>) -> ::capnp::private::layout::StructReader<'a> {
reader.reader
}
}

Expand Down Expand Up @@ -1140,9 +1140,9 @@ pub mod return_ {
}
}

impl <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> {
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
self.reader
impl <'a,> From<Reader<'a,>> for ::capnp::private::layout::StructReader<'a> {
fn from(reader: Reader<'a,>) -> ::capnp::private::layout::StructReader<'a> {
reader.reader
}
}

Expand Down Expand Up @@ -1424,9 +1424,9 @@ pub mod finish {
}
}

impl <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> {
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
self.reader
impl <'a,> From<Reader<'a,>> for ::capnp::private::layout::StructReader<'a> {
fn from(reader: Reader<'a,>) -> ::capnp::private::layout::StructReader<'a> {
reader.reader
}
}

Expand Down Expand Up @@ -1558,9 +1558,9 @@ pub mod resolve {
}
}

impl <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> {
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
self.reader
impl <'a,> From<Reader<'a,>> for ::capnp::private::layout::StructReader<'a> {
fn from(reader: Reader<'a,>) -> ::capnp::private::layout::StructReader<'a> {
reader.reader
}
}

Expand Down Expand Up @@ -1756,9 +1756,9 @@ pub mod release {
}
}

impl <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> {
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
self.reader
impl <'a,> From<Reader<'a,>> for ::capnp::private::layout::StructReader<'a> {
fn from(reader: Reader<'a,>) -> ::capnp::private::layout::StructReader<'a> {
reader.reader
}
}

Expand Down Expand Up @@ -1888,9 +1888,9 @@ pub mod disembargo {
}
}

impl <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> {
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
self.reader
impl <'a,> From<Reader<'a,>> for ::capnp::private::layout::StructReader<'a> {
fn from(reader: Reader<'a,>) -> ::capnp::private::layout::StructReader<'a> {
reader.reader
}
}

Expand Down Expand Up @@ -2041,9 +2041,9 @@ pub mod disembargo {
}
}

impl <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> {
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
self.reader
impl <'a,> From<Reader<'a,>> for ::capnp::private::layout::StructReader<'a> {
fn from(reader: Reader<'a,>) -> ::capnp::private::layout::StructReader<'a> {
reader.reader
}
}

Expand Down Expand Up @@ -2229,9 +2229,9 @@ pub mod provide {
}
}

impl <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> {
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
self.reader
impl <'a,> From<Reader<'a,>> for ::capnp::private::layout::StructReader<'a> {
fn from(reader: Reader<'a,>) -> ::capnp::private::layout::StructReader<'a> {
reader.reader
}
}

Expand Down Expand Up @@ -2401,9 +2401,9 @@ pub mod accept {
}
}

impl <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> {
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
self.reader
impl <'a,> From<Reader<'a,>> for ::capnp::private::layout::StructReader<'a> {
fn from(reader: Reader<'a,>) -> ::capnp::private::layout::StructReader<'a> {
reader.reader
}
}

Expand Down Expand Up @@ -2558,9 +2558,9 @@ pub mod join {
}
}

impl <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> {
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
self.reader
impl <'a,> From<Reader<'a,>> for ::capnp::private::layout::StructReader<'a> {
fn from(reader: Reader<'a,>) -> ::capnp::private::layout::StructReader<'a> {
reader.reader
}
}

Expand Down Expand Up @@ -2732,9 +2732,9 @@ pub mod message_target {
}
}

impl <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> {
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
self.reader
impl <'a,> From<Reader<'a,>> for ::capnp::private::layout::StructReader<'a> {
fn from(reader: Reader<'a,>) -> ::capnp::private::layout::StructReader<'a> {
reader.reader
}
}

Expand Down Expand Up @@ -2903,9 +2903,9 @@ pub mod payload {
}
}

impl <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> {
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
self.reader
impl <'a,> From<Reader<'a,>> for ::capnp::private::layout::StructReader<'a> {
fn from(reader: Reader<'a,>) -> ::capnp::private::layout::StructReader<'a> {
reader.reader
}
}

Expand Down Expand Up @@ -3062,9 +3062,9 @@ pub mod cap_descriptor {
}
}

impl <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> {
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
self.reader
impl <'a,> From<Reader<'a,>> for ::capnp::private::layout::StructReader<'a> {
fn from(reader: Reader<'a,>) -> ::capnp::private::layout::StructReader<'a> {
reader.reader
}
}

Expand Down Expand Up @@ -3323,9 +3323,9 @@ pub mod promised_answer {
}
}

impl <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> {
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
self.reader
impl <'a,> From<Reader<'a,>> for ::capnp::private::layout::StructReader<'a> {
fn from(reader: Reader<'a,>) -> ::capnp::private::layout::StructReader<'a> {
reader.reader
}
}

Expand Down Expand Up @@ -3468,9 +3468,9 @@ pub mod promised_answer {
}
}

impl <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> {
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
self.reader
impl <'a,> From<Reader<'a,>> for ::capnp::private::layout::StructReader<'a> {
fn from(reader: Reader<'a,>) -> ::capnp::private::layout::StructReader<'a> {
reader.reader
}
}

Expand Down Expand Up @@ -3624,9 +3624,9 @@ pub mod third_party_cap_descriptor {
}
}

impl <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> {
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
self.reader
impl <'a,> From<Reader<'a,>> for ::capnp::private::layout::StructReader<'a> {
fn from(reader: Reader<'a,>) -> ::capnp::private::layout::StructReader<'a> {
reader.reader
}
}

Expand Down Expand Up @@ -3769,9 +3769,9 @@ pub mod exception {
}
}

impl <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> {
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
self.reader
impl <'a,> From<Reader<'a,>> for ::capnp::private::layout::StructReader<'a> {
fn from(reader: Reader<'a,>) -> ::capnp::private::layout::StructReader<'a> {
reader.reader
}
}

Expand Down
36 changes: 18 additions & 18 deletions capnp-rpc/src/rpc_twoparty_capnp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ pub mod vat_id {
}
}

impl <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> {
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
self.reader
impl <'a,> From<Reader<'a,>> for ::capnp::private::layout::StructReader<'a> {
fn from(reader: Reader<'a,>) -> ::capnp::private::layout::StructReader<'a> {
reader.reader
}
}

Expand Down Expand Up @@ -172,9 +172,9 @@ pub mod provision_id {
}
}

impl <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> {
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
self.reader
impl <'a,> From<Reader<'a,>> for ::capnp::private::layout::StructReader<'a> {
fn from(reader: Reader<'a,>) -> ::capnp::private::layout::StructReader<'a> {
reader.reader
}
}

Expand Down Expand Up @@ -292,9 +292,9 @@ pub mod recipient_id {
}
}

impl <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> {
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
self.reader
impl <'a,> From<Reader<'a,>> for ::capnp::private::layout::StructReader<'a> {
fn from(reader: Reader<'a,>) -> ::capnp::private::layout::StructReader<'a> {
reader.reader
}
}

Expand Down Expand Up @@ -400,9 +400,9 @@ pub mod third_party_cap_id {
}
}

impl <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> {
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
self.reader
impl <'a,> From<Reader<'a,>> for ::capnp::private::layout::StructReader<'a> {
fn from(reader: Reader<'a,>) -> ::capnp::private::layout::StructReader<'a> {
reader.reader
}
}

Expand Down Expand Up @@ -508,9 +508,9 @@ pub mod join_key_part {
}
}

impl <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> {
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
self.reader
impl <'a,> From<Reader<'a,>> for ::capnp::private::layout::StructReader<'a> {
fn from(reader: Reader<'a,>) -> ::capnp::private::layout::StructReader<'a> {
reader.reader
}
}

Expand Down Expand Up @@ -652,9 +652,9 @@ pub mod join_result {
}
}

impl <'a,> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,> {
fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {
self.reader
impl <'a,> From<Reader<'a,>> for ::capnp::private::layout::StructReader<'a> {
fn from(reader: Reader<'a,>) -> ::capnp::private::layout::StructReader<'a> {
reader.reader
}
}

Expand Down
16 changes: 5 additions & 11 deletions capnp/src/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,22 @@

//! Functions providing low level access to encoded data.

use crate::traits::{IntoInternalListReader, IntoInternalStructReader};
use crate::{private::layout::StructReader, traits::IntoInternalListReader};

/// Gets a slice view of the data section of a struct.
pub fn get_struct_data_section<'a, T>(value: T) -> &'a [u8]
where
T: IntoInternalStructReader<'a>,
T: Into<StructReader<'a>>,
{
value
.into_internal_struct_reader()
.get_data_section_as_blob()
value.into().get_data_section_as_blob()
}

/// Gets the pointer section as a list.
pub fn get_struct_pointer_section<'a, T>(value: T) -> crate::any_pointer_list::Reader<'a>
where
T: IntoInternalStructReader<'a>,
T: Into<StructReader<'a>>,
{
crate::any_pointer_list::Reader::new(
value
.into_internal_struct_reader()
.get_pointer_section_as_list(),
)
crate::any_pointer_list::Reader::new(value.into().get_pointer_section_as_list())
}

/// Gets the size of the elements in a list.
Expand Down
7 changes: 3 additions & 4 deletions capnp/src/struct_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
use core::marker::PhantomData;

use crate::private::layout::{
InlineComposite, ListBuilder, ListReader, PointerBuilder, PointerReader,
InlineComposite, ListBuilder, ListReader, PointerBuilder, PointerReader, StructReader,
};
use crate::traits::{
FromPointerBuilder, FromPointerReader, FromStructBuilder, FromStructReader, HasStructSize,
Expand Down Expand Up @@ -186,12 +186,11 @@ where
/// truncated, losing fields.
pub fn set_with_caveats<'b>(&self, index: u32, value: T::Reader<'b>) -> Result<()>
where
T::Reader<'b>: crate::traits::IntoInternalStructReader<'b>,
T::Reader<'b>: Into<StructReader<'b>>,
{
use crate::traits::IntoInternalStructReader;
self.builder
.get_struct_element(index)
.copy_content_from(&value.into_internal_struct_reader())
.copy_content_from(&value.into())
}
}

Expand Down
Loading