Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/tls_codec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
toolchain: ${{ matrix.rust }}
targets: ${{ matrix.target }}
- uses: RustCrypto/actions/cargo-hack-install@master
- run: cargo hack build --target ${{ matrix.target }} --feature-powerset --exclude-features std,default,derive,serde,arbitrary
- run: cargo hack build --target ${{ matrix.target }} --feature-powerset --exclude-features std,default,serde,arbitrary

minimal-versions:
uses: RustCrypto/actions/.github/workflows/minimal-versions.yml@master
Expand Down Expand Up @@ -70,4 +70,4 @@ jobs:
- run: ${{ matrix.deps }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there's a typo in the matrix "targets" -> "target".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this PR is merged, I'll handle the typo as part of another PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, for some reason this works even with this typo. I'm not entirely sure why. But the linter complained.

- uses: RustCrypto/actions/cargo-hack-install@master
- run: cargo hack test --feature-powerset
- run: cargo hack test -p tls_codec_derive --test encode\* --test decode\*
- run: cargo hack test -p tls_codec_derive --feature-powerset --test encode\* --test decode\*
Comment thread
franziskuskiefer marked this conversation as resolved.
4 changes: 2 additions & 2 deletions tls_codec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ regex = "1.8"
[features]
default = [ "std" ]
arbitrary = [ "std", "dep:arbitrary" ]
derive = [ "std", "tls_codec_derive" ]
derive = [ "tls_codec_derive" ]
serde = [ "std", "dep:serde" ]
mls = [] # In MLS variable length vectors are limited compared to QUIC.
std = []
std = [ "tls_codec_derive?/std" ]

[[bench]]
name = "tls_vec"
Expand Down
4 changes: 4 additions & 0 deletions tls_codec/derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ proc-macro2 = "1.0"
[dev-dependencies]
tls_codec = { path = "../" }
trybuild = "1"

[features]
default = [ "std" ]
std = []
8 changes: 7 additions & 1 deletion tls_codec/derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ fn impl_tls_size(parsed_ast: TlsStruct) -> TokenStream2 {
let field_len = match self {
#(#field_arms)*
};
std::mem::size_of::<#repr>() + field_len
core::mem::size_of::<#repr>() + field_len
}
}

Expand Down Expand Up @@ -740,6 +740,7 @@ fn impl_serialize(parsed_ast: TlsStruct, svariant: SerializeVariant) -> TokenStr
SerializeVariant::Write => {
quote! {
impl #impl_generics tls_codec::Serialize for #ident #ty_generics #where_clause {
#[cfg(feature = "std")]
fn tls_serialize<W: std::io::Write>(&self, writer: &mut W) -> core::result::Result<usize, tls_codec::Error> {
let mut written = 0usize;
#(
Expand All @@ -760,6 +761,7 @@ fn impl_serialize(parsed_ast: TlsStruct, svariant: SerializeVariant) -> TokenStr
}

impl #impl_generics tls_codec::Serialize for &#ident #ty_generics #where_clause {
#[cfg(feature = "std")]
fn tls_serialize<W: std::io::Write>(&self, writer: &mut W) -> core::result::Result<usize, tls_codec::Error> {
tls_codec::Serialize::tls_serialize(*self, writer)
}
Expand Down Expand Up @@ -850,6 +852,7 @@ fn impl_serialize(parsed_ast: TlsStruct, svariant: SerializeVariant) -> TokenStr
SerializeVariant::Write => {
quote! {
impl #impl_generics tls_codec::Serialize for #ident #ty_generics #where_clause {
#[cfg(feature = "std")]
fn tls_serialize<W: std::io::Write>(&self, writer: &mut W) -> core::result::Result<usize, tls_codec::Error> {
#discriminant_constants
match self {
Expand All @@ -859,6 +862,7 @@ fn impl_serialize(parsed_ast: TlsStruct, svariant: SerializeVariant) -> TokenStr
}

impl #impl_generics tls_codec::Serialize for &#ident #ty_generics #where_clause {
#[cfg(feature = "std")]
fn tls_serialize<W: std::io::Write>(&self, writer: &mut W) -> core::result::Result<usize, tls_codec::Error> {
tls_codec::Serialize::tls_serialize(*self, writer)
}
Expand Down Expand Up @@ -909,6 +913,7 @@ fn impl_deserialize(parsed_ast: TlsStruct) -> TokenStream2 {
let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
quote! {
impl #impl_generics tls_codec::Deserialize for #ident #ty_generics #where_clause {
#[cfg(feature = "std")]
fn tls_deserialize<R: std::io::Read>(bytes: &mut R) -> core::result::Result<Self, tls_codec::Error> {
Ok(Self {
#(#members: #prefixes::tls_deserialize(bytes)?,)*
Expand Down Expand Up @@ -948,6 +953,7 @@ fn impl_deserialize(parsed_ast: TlsStruct) -> TokenStream2 {
quote! {
impl #impl_generics tls_codec::Deserialize for #ident #ty_generics #where_clause {
#[allow(non_upper_case_globals)]
#[cfg(feature = "std")]
fn tls_deserialize<R: std::io::Read>(bytes: &mut R) -> core::result::Result<Self, tls_codec::Error> {
#discriminant_constants
let discriminant = <#repr as tls_codec::Deserialize>::tls_deserialize(bytes)?;
Expand Down
1 change: 1 addition & 0 deletions tls_codec/derive/tests/decode.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg(feature = "std")]
use tls_codec::{
Deserialize, Error, Serialize, Size, TlsSliceU16, TlsVecU16, TlsVecU32, TlsVecU8, VLBytes,
};
Expand Down
Loading