Giter VIP home page Giter VIP logo

Comments (9)

cpu avatar cpu commented on June 15, 2024 1

👋 Thanks for filing this detailed issue!

I think in general since the unbuffered API surface is so new it hasn't seen a lot of downstream usage and feedback on the ergonomics and remaining rough edges is very helpful.

It would be nice if Rustls creates it's own trait for some kind of Rustls relevant Buffer type which has capacity that can be passed as generic to these implementations.

This seems reasonable to me, but I suspect I have less opinions on this area than the other maintainers.

Most ideally this trait could be "isolated" within a separate crate to let other implementers to follow about it without necessary pulling the whole rustls for use-cases where given implementer crate only implements underlying buffer but not other parts of rustls.

I'm not sure I understand what value there would be in only implementing the buffer without intent to integrate with Rustls as a larger goal but in either case, perhaps this could be something that's a fit for the pki-types crate? It seems conceivable that it would be useful in other Rustls crates as well.

I would be more than happy to send a PR if you would be amenable to something like this or something else which potentially could maybe reduce the need of zero-initialization and ensuring the output is sized correctly for sending out.

I think before going too far down that road it would make sense to check that djc and ctz are on board with the general premise + proposed solution. If they are, I'd be happy to try and review. I've had to pause my own work on reducing the bifurcation of the buffered/unbuffered APIs to focus on other areas but I think I could find the time to support this.

If this is not feasible then I could send a PR to document this perhaps to ensure nobody else steps into this little footgun I did.

That sounds worthwhile, thank you!

from rustls.

ctz avatar ctz commented on June 15, 2024 1

BorrowedBuf is in core::io

from rustls.

djc avatar djc commented on June 15, 2024 1

Sounds okay to me!

from rustls.

djc avatar djc commented on June 15, 2024

I feel like we should rely on the std BorrowedBuf and co here? Those are still unstable but I don't love the idea of reinventing that stuff ahead of them becoming stable.

from rustls.

pinkforest avatar pinkforest commented on June 15, 2024

That would require std though ? unbuffered typically operates in no_std context at least for /some of/ my use-cases.

from rustls.

pinkforest avatar pinkforest commented on June 15, 2024

Ah thanks for pointing that out - my bad

It doesn't on quick glance work for io_uring case though as it requires owned buffers due to kernel/userspace sharing ?

EDIT: I might have most definitely misunderstood how to use BorrowedCursor as owned - I need to check that

from rustls.

pinkforest avatar pinkforest commented on June 15, 2024

Would you be okay with experimental support via BorrowedBuf via PR if I hook it up ?

e.g. encode could be encode_borrowed() so it doesn't disturb the existing API and is over cfg-feature-gate e.g. borrowed_buf for unbuffered ?

from rustls.

pinkforest avatar pinkforest commented on June 15, 2024

Sweet, PR on your way soon(tm)

from rustls.

pinkforest avatar pinkforest commented on June 15, 2024

Also if there is appetite to check feature use vs used rustc version given the version-dependant feature -

We could either check nightly in build.rs or just add fallible feature if someone tries to use the feature at stable that doesn't have the said feature.

e.g. detecting nightly w/ rustc_version crate and relaying appropriate cfg-gating

    if rustc_version::version_meta()
        .expect("failed to detect rustc version")
        .channel
        == rustc_version::Channel::Nightly
    {
        println!("cargo:rustc-cfg=nightly");
    }

With dalek we also have AVX2 gated for stable rust as below and nightly for AVX512
e.g. when the feature stabilises this could be used to guard it's use - if needed / wanted ?

    let rustc_version = rustc_version::version().expect("failed to detect rustc version");
    if rustc_version.major == 1 && rustc_version.minor <= 64 {
        // Old versions of Rust complain when you have an `unsafe fn` and you use `unsafe {}` inside,
        // so for those we want to apply the `#[allow(unused_unsafe)]` attribute to get rid of that warning.
        println!("cargo:rustc-cfg=allow_unused_unsafe");
    }

EDIT: Looks like there is already nightly check .. and for read-buf 🤦‍♀️ can just extend that 😅

from rustls.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.