pub struct ModuleFlags(/* private fields */);Expand description
Module access flags used in Java class files.
The ModuleAccessFlags type represents the access flags in the Module attribute of a Java
class file.
§Examples
use ristretto_classfile::byte_reader::ByteReader;
use ristretto_classfile::attributes::ModuleAccessFlags;
// Create flags using individual constants
let flags = ModuleAccessFlags::OPEN | ModuleAccessFlags::SYNTHETIC;
// Test for specific flags
assert!(flags.contains(ModuleAccessFlags::OPEN));
assert!(flags.contains(ModuleAccessFlags::SYNTHETIC));
assert!(!flags.contains(ModuleAccessFlags::MANDATED));
// Convert to string representation
assert_eq!(flags.to_string(), "(0x1020) ACC_OPEN, ACC_SYNTHETIC");
// Serialize to bytes
let mut bytes = Vec::new();
flags.to_bytes(&mut bytes)?;
assert_eq!(bytes, vec![0x10, 0x20]);
// Deserialize from bytes
let mut reader = ByteReader::new(&bytes);
let deserialized = ModuleAccessFlags::from_bytes(&mut reader)?;
assert_eq!(deserialized, flags);§References
Implementations§
Source§impl ModuleAccessFlags
impl ModuleAccessFlags
Sourcepub const OPEN: ModuleAccessFlags
pub const OPEN: ModuleAccessFlags
Indicates that this module is open.
Sourcepub const SYNTHETIC: ModuleAccessFlags
pub const SYNTHETIC: ModuleAccessFlags
Indicates that this module was not explicitly or implicitly declared.
Sourcepub const MANDATED: ModuleAccessFlags
pub const MANDATED: ModuleAccessFlags
Indicates that this module was implicitly declared.
Source§impl ModuleAccessFlags
impl ModuleAccessFlags
Sourcepub const fn empty() -> ModuleAccessFlags
pub const fn empty() -> ModuleAccessFlags
Get a flags value with all bits unset.
Sourcepub const fn all() -> ModuleAccessFlags
pub const fn all() -> ModuleAccessFlags
Get a flags value with all known bits set.
Sourcepub const fn bits(&self) -> u16
pub const fn bits(&self) -> u16
Get the underlying bits value.
The returned value is exactly the bits set in this flags value.
Sourcepub const fn from_bits(bits: u16) -> Option<ModuleAccessFlags>
pub const fn from_bits(bits: u16) -> Option<ModuleAccessFlags>
Convert from a bits value.
This method will return None if any unknown bits are set.
Sourcepub const fn from_bits_truncate(bits: u16) -> ModuleAccessFlags
pub const fn from_bits_truncate(bits: u16) -> ModuleAccessFlags
Convert from a bits value, unsetting any unknown bits.
Sourcepub const fn from_bits_retain(bits: u16) -> ModuleAccessFlags
pub const fn from_bits_retain(bits: u16) -> ModuleAccessFlags
Convert from a bits value exactly.
Sourcepub fn from_name(name: &str) -> Option<ModuleAccessFlags>
pub fn from_name(name: &str) -> Option<ModuleAccessFlags>
Get a flags value with the bits of a flag with the given name set.
This method will return None if name is empty or doesn’t
correspond to any named flag.
Sourcepub const fn intersects(&self, other: ModuleAccessFlags) -> bool
pub const fn intersects(&self, other: ModuleAccessFlags) -> bool
Whether any set bits in a source flags value are also set in a target flags value.
Sourcepub const fn contains(&self, other: ModuleAccessFlags) -> bool
pub const fn contains(&self, other: ModuleAccessFlags) -> bool
Whether all set bits in a source flags value are also set in a target flags value.
Sourcepub fn insert(&mut self, other: ModuleAccessFlags)
pub fn insert(&mut self, other: ModuleAccessFlags)
The bitwise or (|) of the bits in two flags values.
Sourcepub fn remove(&mut self, other: ModuleAccessFlags)
pub fn remove(&mut self, other: ModuleAccessFlags)
The intersection of a source flags value with the complement of a target flags
value (&!).
This method is not equivalent to self & !other when other has unknown bits set.
remove won’t truncate other, but the ! operator will.
Sourcepub fn toggle(&mut self, other: ModuleAccessFlags)
pub fn toggle(&mut self, other: ModuleAccessFlags)
The bitwise exclusive-or (^) of the bits in two flags values.
Sourcepub fn set(&mut self, other: ModuleAccessFlags, value: bool)
pub fn set(&mut self, other: ModuleAccessFlags, value: bool)
Call insert when value is true or remove when value is false.
Sourcepub const fn intersection(self, other: ModuleAccessFlags) -> ModuleAccessFlags
pub const fn intersection(self, other: ModuleAccessFlags) -> ModuleAccessFlags
The bitwise and (&) of the bits in two flags values.
Sourcepub const fn union(self, other: ModuleAccessFlags) -> ModuleAccessFlags
pub const fn union(self, other: ModuleAccessFlags) -> ModuleAccessFlags
The bitwise or (|) of the bits in two flags values.
Sourcepub const fn difference(self, other: ModuleAccessFlags) -> ModuleAccessFlags
pub const fn difference(self, other: ModuleAccessFlags) -> ModuleAccessFlags
The intersection of a source flags value with the complement of a target flags
value (&!).
This method is not equivalent to self & !other when other has unknown bits set.
difference won’t truncate other, but the ! operator will.
Sourcepub const fn symmetric_difference(
self,
other: ModuleAccessFlags,
) -> ModuleAccessFlags
pub const fn symmetric_difference( self, other: ModuleAccessFlags, ) -> ModuleAccessFlags
The bitwise exclusive-or (^) of the bits in two flags values.
Sourcepub const fn complement(self) -> ModuleAccessFlags
pub const fn complement(self) -> ModuleAccessFlags
The bitwise negation (!) of the bits in a flags value, truncating the result.
Source§impl ModuleAccessFlags
impl ModuleAccessFlags
Sourcepub const fn iter(&self) -> Iter<ModuleAccessFlags>
pub const fn iter(&self) -> Iter<ModuleAccessFlags>
Yield a set of contained flags values.
Each yielded flags value will correspond to a defined named flag. Any unknown bits will be yielded together as a final flags value.
Sourcepub const fn iter_names(&self) -> IterNames<ModuleAccessFlags>
pub const fn iter_names(&self) -> IterNames<ModuleAccessFlags>
Yield a set of contained named flags values.
This method is like iter, except only yields bits in contained named flags.
Any unknown bits, or bits not corresponding to a contained flag will not be yielded.
Source§impl ModuleAccessFlags
impl ModuleAccessFlags
Sourcepub fn from_bytes(
bytes: &mut ByteReader<'_>,
) -> Result<ModuleAccessFlags, Error>
pub fn from_bytes( bytes: &mut ByteReader<'_>, ) -> Result<ModuleAccessFlags, Error>
Deserialize the ModuleAccessFlags from bytes.
§Errors
Should not occur; reserved for future use.
§Examples
use ristretto_classfile::byte_reader::ByteReader;
use ristretto_classfile::attributes::ModuleAccessFlags;
let mut bytes = ByteReader::new(&[0x00, 0x20]); // ACC_OPEN
let flags = ModuleAccessFlags::from_bytes(&mut bytes)?;
assert_eq!(flags, ModuleAccessFlags::OPEN);Sourcepub fn to_bytes(&self, bytes: &mut Vec<u8>) -> Result<(), Error>
pub fn to_bytes(&self, bytes: &mut Vec<u8>) -> Result<(), Error>
Serialize the ModuleAccessFlags to bytes.
§Errors
Should not occur; reserved for future use.
§Examples
use ristretto_classfile::attributes::ModuleAccessFlags;
let flags = ModuleAccessFlags::OPEN | ModuleAccessFlags::SYNTHETIC;
let mut bytes = Vec::new();
flags.to_bytes(&mut bytes)?;
assert_eq!(bytes, vec![0x10, 0x20]); // 0x0020 | 0x1000Trait Implementations§
Source§impl Binary for ModuleAccessFlags
impl Binary for ModuleAccessFlags
Source§impl BitAnd for ModuleAccessFlags
impl BitAnd for ModuleAccessFlags
Source§fn bitand(self, other: ModuleAccessFlags) -> ModuleAccessFlags
fn bitand(self, other: ModuleAccessFlags) -> ModuleAccessFlags
The bitwise and (&) of the bits in two flags values.
Source§type Output = ModuleAccessFlags
type Output = ModuleAccessFlags
& operator.Source§impl BitAndAssign for ModuleAccessFlags
impl BitAndAssign for ModuleAccessFlags
Source§fn bitand_assign(&mut self, other: ModuleAccessFlags)
fn bitand_assign(&mut self, other: ModuleAccessFlags)
The bitwise and (&) of the bits in two flags values.
Source§impl BitOr for ModuleAccessFlags
impl BitOr for ModuleAccessFlags
Source§fn bitor(self, other: ModuleAccessFlags) -> ModuleAccessFlags
fn bitor(self, other: ModuleAccessFlags) -> ModuleAccessFlags
The bitwise or (|) of the bits in two flags values.
Source§type Output = ModuleAccessFlags
type Output = ModuleAccessFlags
| operator.Source§impl BitOrAssign for ModuleAccessFlags
impl BitOrAssign for ModuleAccessFlags
Source§fn bitor_assign(&mut self, other: ModuleAccessFlags)
fn bitor_assign(&mut self, other: ModuleAccessFlags)
The bitwise or (|) of the bits in two flags values.
Source§impl BitXor for ModuleAccessFlags
impl BitXor for ModuleAccessFlags
Source§fn bitxor(self, other: ModuleAccessFlags) -> ModuleAccessFlags
fn bitxor(self, other: ModuleAccessFlags) -> ModuleAccessFlags
The bitwise exclusive-or (^) of the bits in two flags values.
Source§type Output = ModuleAccessFlags
type Output = ModuleAccessFlags
^ operator.Source§impl BitXorAssign for ModuleAccessFlags
impl BitXorAssign for ModuleAccessFlags
Source§fn bitxor_assign(&mut self, other: ModuleAccessFlags)
fn bitxor_assign(&mut self, other: ModuleAccessFlags)
The bitwise exclusive-or (^) of the bits in two flags values.
Source§impl Clone for ModuleAccessFlags
impl Clone for ModuleAccessFlags
Source§fn clone(&self) -> ModuleAccessFlags
fn clone(&self) -> ModuleAccessFlags
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ModuleAccessFlags
impl Debug for ModuleAccessFlags
Source§impl Default for ModuleAccessFlags
impl Default for ModuleAccessFlags
Source§fn default() -> ModuleAccessFlags
fn default() -> ModuleAccessFlags
Source§impl Display for ModuleAccessFlags
impl Display for ModuleAccessFlags
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>
Implements the Display trait for ModuleAccessFlags, allowing flags to be printed in a human-readable format.
The output format consists of:
- The hexadecimal value of the flags in parentheses (e.g., “(0x0020)”)
- A list of named flags separated by commas (e.g., “
ACC_OPEN, ACC_SYNTHETIC”)
§Examples
use ristretto_classfile::attributes::ModuleAccessFlags;
let flags = ModuleAccessFlags::OPEN | ModuleAccessFlags::SYNTHETIC;
let output = flags.to_string();
assert_eq!(output, "(0x1020) ACC_OPEN, ACC_SYNTHETIC");
let empty = ModuleAccessFlags::empty();
assert_eq!(empty.to_string(), "(0x0000) ");Source§impl Extend<ModuleAccessFlags> for ModuleAccessFlags
impl Extend<ModuleAccessFlags> for ModuleAccessFlags
Source§fn extend<T>(&mut self, iterator: T)where
T: IntoIterator<Item = ModuleAccessFlags>,
fn extend<T>(&mut self, iterator: T)where
T: IntoIterator<Item = ModuleAccessFlags>,
The bitwise or (|) of the bits in each flags value.
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl Flags for ModuleAccessFlags
impl Flags for ModuleAccessFlags
Source§const FLAGS: &'static [Flag<ModuleAccessFlags>]
const FLAGS: &'static [Flag<ModuleAccessFlags>]
Source§fn from_bits_retain(bits: u16) -> ModuleAccessFlags
fn from_bits_retain(bits: u16) -> ModuleAccessFlags
Source§fn known_bits(&self) -> Self::Bits
fn known_bits(&self) -> Self::Bits
Source§fn unknown_bits(&self) -> Self::Bits
fn unknown_bits(&self) -> Self::Bits
Source§fn contains_unknown_bits(&self) -> bool
fn contains_unknown_bits(&self) -> bool
true if any unknown bits are set.Source§fn from_bits_truncate(bits: Self::Bits) -> Self
fn from_bits_truncate(bits: Self::Bits) -> Self
Source§fn from_name(name: &str) -> Option<Self>
fn from_name(name: &str) -> Option<Self>
Source§fn iter_names(&self) -> IterNames<Self>
fn iter_names(&self) -> IterNames<Self>
Source§fn iter_defined_names() -> IterDefinedNames<Self>
fn iter_defined_names() -> IterDefinedNames<Self>
Self::FLAGS.Source§fn intersects(&self, other: Self) -> boolwhere
Self: Sized,
fn intersects(&self, other: Self) -> boolwhere
Self: Sized,
Source§fn contains(&self, other: Self) -> boolwhere
Self: Sized,
fn contains(&self, other: Self) -> boolwhere
Self: Sized,
Source§fn insert(&mut self, other: Self)where
Self: Sized,
fn insert(&mut self, other: Self)where
Self: Sized,
|) of the bits in two flags values.Source§fn remove(&mut self, other: Self)where
Self: Sized,
fn remove(&mut self, other: Self)where
Self: Sized,
&!). Read moreSource§fn toggle(&mut self, other: Self)where
Self: Sized,
fn toggle(&mut self, other: Self)where
Self: Sized,
^) of the bits in two flags values.Source§fn intersection(self, other: Self) -> Self
fn intersection(self, other: Self) -> Self
&) of the bits in two flags values.Source§fn difference(self, other: Self) -> Self
fn difference(self, other: Self) -> Self
&!). Read moreSource§fn symmetric_difference(self, other: Self) -> Self
fn symmetric_difference(self, other: Self) -> Self
^) of the bits in two flags values.Source§fn complement(self) -> Self
fn complement(self) -> Self
!) of the bits in a flags value, truncating the result.Source§impl FromIterator<ModuleAccessFlags> for ModuleAccessFlags
impl FromIterator<ModuleAccessFlags> for ModuleAccessFlags
Source§fn from_iter<T>(iterator: T) -> ModuleAccessFlagswhere
T: IntoIterator<Item = ModuleAccessFlags>,
fn from_iter<T>(iterator: T) -> ModuleAccessFlagswhere
T: IntoIterator<Item = ModuleAccessFlags>,
The bitwise or (|) of the bits in each flags value.
Source§impl IntoIterator for ModuleAccessFlags
impl IntoIterator for ModuleAccessFlags
Source§type Item = ModuleAccessFlags
type Item = ModuleAccessFlags
Source§type IntoIter = Iter<ModuleAccessFlags>
type IntoIter = Iter<ModuleAccessFlags>
Source§fn into_iter(self) -> <ModuleAccessFlags as IntoIterator>::IntoIter
fn into_iter(self) -> <ModuleAccessFlags as IntoIterator>::IntoIter
Source§impl LowerHex for ModuleAccessFlags
impl LowerHex for ModuleAccessFlags
Source§impl Not for ModuleAccessFlags
impl Not for ModuleAccessFlags
Source§fn not(self) -> ModuleAccessFlags
fn not(self) -> ModuleAccessFlags
The bitwise negation (!) of the bits in a flags value, truncating the result.
Source§type Output = ModuleAccessFlags
type Output = ModuleAccessFlags
! operator.Source§impl Octal for ModuleAccessFlags
impl Octal for ModuleAccessFlags
Source§impl PartialEq for ModuleAccessFlags
impl PartialEq for ModuleAccessFlags
Source§impl Sub for ModuleAccessFlags
impl Sub for ModuleAccessFlags
Source§fn sub(self, other: ModuleAccessFlags) -> ModuleAccessFlags
fn sub(self, other: ModuleAccessFlags) -> ModuleAccessFlags
The intersection of a source flags value with the complement of a target flags value (&!).
This method is not equivalent to self & !other when other has unknown bits set.
difference won’t truncate other, but the ! operator will.
Source§type Output = ModuleAccessFlags
type Output = ModuleAccessFlags
- operator.Source§impl SubAssign for ModuleAccessFlags
impl SubAssign for ModuleAccessFlags
Source§fn sub_assign(&mut self, other: ModuleAccessFlags)
fn sub_assign(&mut self, other: ModuleAccessFlags)
The intersection of a source flags value with the complement of a target flags value (&!).
This method is not equivalent to self & !other when other has unknown bits set.
difference won’t truncate other, but the ! operator will.
Source§impl UpperHex for ModuleAccessFlags
impl UpperHex for ModuleAccessFlags
impl Copy for ModuleAccessFlags
impl Eq for ModuleAccessFlags
impl StructuralPartialEq for ModuleAccessFlags
Auto Trait Implementations§
impl Freeze for ModuleAccessFlags
impl RefUnwindSafe for ModuleAccessFlags
impl Send for ModuleAccessFlags
impl Sync for ModuleAccessFlags
impl Unpin for ModuleAccessFlags
impl UnsafeUnpin for ModuleAccessFlags
impl UnwindSafe for ModuleAccessFlags
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.