Coder Social home page Coder Social logo

Comments (5)

biryukovmaxim avatar biryukovmaxim commented on May 21, 2024 1

Hey, I think that's not flexible enough, go and js implementations use String, but I can suggest using generic type Clone + Eq + Hash. If type is Copy it is easy to implement Clone for it.
It cab be implemented with Generator trait

pub trait Generator: Clone + Sync + Send + 'static + Debug {
    type Sid: Clone + Hash + Eq + Debug + Display + FromStr;
    fn generate_sid(&self) -> Self::Sid;
}

What do you think about it?

from socketioxide.

biryukovmaxim avatar biryukovmaxim commented on May 21, 2024 1

I created a PR.
I haven't fixed docs test, it expects addition of type annotations.
From my point of view it can make project more complicated and less developer friendly.
Could you check it out? Now I'm not sure if it's really worth it

from socketioxide.

Totodore avatar Totodore commented on May 21, 2024 1

As I said in your PR, it is maybe not the best moment to add so much complexity to the codebase due to the generic.
However you can still make a fixed implementation of a fully random, fixed size generated socket id. It is the part that's bother me the most because snowflakes are predictible.

from socketioxide.

Totodore avatar Totodore commented on May 21, 2024

I like the idea of a Generator trait so it allows the user to specify a custom generator function.

But it would imply to propagate another generic all around the codebase.

Idk if it is worth it but why not try and see the result !

Are you considering working on it ?

from socketioxide.

Totodore avatar Totodore commented on May 21, 2024

Resolved with #19

from socketioxide.

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.