pub struct ConstantPool { /* private fields */ }Expand description
A JVM constant pool. See the JVM Specification §4.4 for more information.
Implementations§
Source§impl ConstantPool
impl ConstantPool
Sourcepub fn with_capacity(count: u16) -> Self
pub fn with_capacity(count: u16) -> Self
Creates a new constant pool with the given capacity.
§Parameters
count: the maximum index of entries in the constant pool plus one.
Sourcepub fn from_reader<R>(reader: &mut R, constant_pool_count: u16) -> Result<Self>
pub fn from_reader<R>(reader: &mut R, constant_pool_count: u16) -> Result<Self>
Parses a constant pool from the given bytes.
constant_pool_countis the maximum index of entries in the constant pool plus one. See the JVM Specification §4.1 for more information.
§Errors
See io::Error for more information.
Sourcepub fn get_entry(&self, index: u16) -> Option<&Entry>
pub fn get_entry(&self, index: u16) -> Option<&Entry>
Gets the constant pool entry at the given index.
Returns None if the index is out of bounds or the index does not point to a valid slot.
Sourcepub fn put_entry(&mut self, entry: Entry) -> Result<u16, Overflow>
pub fn put_entry(&mut self, entry: Entry) -> Result<u16, Overflow>
Put a constant pool entry to the end of the constant pool and return the index of the inserted entry.
§Errors
Returns back the entry if the constant pool is full (i.e., contains more than 65535 slots).
Sourcepub fn put_entry_deduplicated(
&mut self,
entry: Entry,
) -> Result<(u16, bool), Overflow>
pub fn put_entry_deduplicated( &mut self, entry: Entry, ) -> Result<(u16, bool), Overflow>
Pushes a constant pool entry to the end of the constant pool if it does not already exist.
§Return Values
Ok with a tuple indicating the index of the entry within the constant pool, and whether the entry is freshly
inserted into the pool.
§Errors
Returns back the entry if the constant pool is full (i.e., contains more than 65535 slots).
Sourcepub fn find<P>(&self, predicate: P) -> Option<(u16, &Entry)>
pub fn find<P>(&self, predicate: P) -> Option<(u16, &Entry)>
Finds the first constant pool entry that satisfies the given predicate.
Sourcepub fn count(&self) -> u16
pub fn count(&self) -> u16
Gets the count of the constant pool. Note that this is NOT the number of entries. See the JVM Specification §4.1 for more information.
Trait Implementations§
Source§impl Clone for ConstantPool
impl Clone for ConstantPool
Source§fn clone(&self) -> ConstantPool
fn clone(&self) -> ConstantPool
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ConstantPool
impl Debug for ConstantPool
Source§impl Default for ConstantPool
impl Default for ConstantPool
Source§impl PartialEq for ConstantPool
impl PartialEq for ConstantPool
impl Eq for ConstantPool
impl StructuralPartialEq for ConstantPool
Auto Trait Implementations§
impl Freeze for ConstantPool
impl RefUnwindSafe for ConstantPool
impl Send for ConstantPool
impl Sync for ConstantPool
impl Unpin for ConstantPool
impl UnwindSafe for ConstantPool
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<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 more