Skip to content

Question: Correct use of type alias? #50

@the-moog

Description

@the-moog

There are type alias for producers and consumbers, namely Prod and Cons that depend on the storage used.

If I try and put those type alises into a structure I need to define the type, but I have no idea what that type should be.

e.g.

use ringbuf::{traits::*, HeapRb, Prod, Cons};

pub struct SerialBuffer {
    fifo: HeapRb<u8>,
    prod: Prod<P>.
    cons: Cons<C>
}

impl Default for SerialBuffer {
    fn default() -> Self {
        let mut fifo = HeapRb::<u8>:new(100);
        let (mut prod, mut cons) = fifo.split();

        Self {
            fifo: fifo,
            prod: prod,
            cons: cons
        }
    }
}

What are the types for P and C?

I've tried the obvious u8 and Arc<u8> but neither are accepted. I've looked through the code and examples with no luck....

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