Skip to content

MemoryProtection type issues #29

@twizmwazin

Description

@twizmwazin

Problem

Currently, icicle-python is using an enum to represent memory protection:

#[pyclass(eq, eq_int, module = "icicle")]
#[derive(Clone, Debug, PartialEq)]
pub enum MemoryProtection {
    NoAccess,
    ReadOnly,
    ReadWrite,
    ExecuteOnly,
    ExecuteRead,
    ExecuteReadWrite,
}

There are two issues I have come across with this:

  1. This enum is not exhaustive, It is missing WriteOnly and ExecuteWrite options (certainly rare but these do occur)
  2. Cannot construct using or operations, for example to construct permissions like so: read_bit | write_bit | exec_bit.

Proposed solutions

Option 1: Just use a u8

This is what Icicle is already doing, and I think simplicity is the best approach here. Users are probably already familiar with this encoding and it has minimal overhead since it is a primitive type.

Option 2: Improve enum and implement __or__

This has the benefit that it should maintain compatibility while resolving the issues above. Downside is that this seems maybe excessive for just representing a u8.

Let me know if you have any thoughts and I can prepare a PR for either option.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions