Skip to content

Integrate ptr_at function in the crate? #1420

@ThomasCartier

Description

@ThomasCartier

Hi,

Is it reasonable to integrate

#[inline(always)] 
fn ptr_at<T>(ctx: &XdpContext, offset: usize) -> Result<*const T, ()> {

        let start = ctx.data();

        let end = ctx.data_end();

        let len = mem::size_of::<T>();

        if start + offset + len > end {

                return Err(());
        }

        Ok((start + offset) as *const T)
}

into the crate so that we don't have to write it ourselves? That's a tiny dev experience improvement (in a very good crate).
It's generic enough so it should not be an issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions