Skip to content

edge-mdns::io::Mdns rand type #60

Open
@Georges760

Description

@Georges760

Currently:

pub struct Mdns<'a, M, R, S, RB, SB>
where
    M: RawMutex,
{
    ipv4_interface: Option<Ipv4Addr>,
    ipv6_interface: Option<u32>,
    recv: Mutex<M, R>,
    send: Mutex<M, S>,
    recv_buf: RB,
    send_buf: SB,
    rand: fn(&mut [u8]),
    broadcast_signal: &'a Signal<M, ()>,
    wait_readable: bool,
}

why not having rand being a generic type that implement rand::RngCore ?

Something like:

pub struct Mdns<'a, M, R, S, RB, SB, RNG>
where
    M: RawMutex,
    RNG: rand::RngCore,
{
    ipv4_interface: Option<Ipv4Addr>,
    ipv6_interface: Option<u32>,
    recv: Mutex<M, R>,
    send: Mutex<M, S>,
    recv_buf: RB,
    send_buf: SB,
    rand: RNG,
    broadcast_signal: &'a Signal<M, ()>,
    wait_readable: bool,
}

because having this fonction prototype implies that the Random Number Generator need to be static and use within the fn without being passed as parameter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions