pub struct Segment<T: AsRef<[u8]>, B> { /* private fields */ }Expand description
Binary consisting of a single segment of encoded Instructions
This Binary serves a single buffer as a code segment starting from
address 0.
§Example
The following example builds a segment at a specifig offset:
use riscv_etrace::binary::{self, Adaptable, Binary};
use riscv_etrace::instruction::{self, base};
let bootrom = b"\x97\x02\x00\x00\x93\x85\x02\x02\x73\x25\x40\xf1\x83\xb2\x82\x01\x67\x80\x02\x00";
let mut bootrom = binary::from_segment(bootrom, base::Set::Rv64I)
.with_offset(0x1000);
assert_eq!(
bootrom.get_insn(0x1010),
Ok(instruction::Kind::new_jalr(0, 5, 0).into()),
);Implementations§
Trait Implementations§
Source§impl<T: AsRef<[u8]>, B: Decode<I>, I: Info> Binary<I> for Segment<T, B>
impl<T: AsRef<[u8]>, B: Decode<I>, I: Info> Binary<I> for Segment<T, B>
Source§type Error = SegmentError
type Error = SegmentError
Error type returned by
get_insnSource§fn get_insn(&mut self, address: u64) -> Result<Instruction<I>, Self::Error>
fn get_insn(&mut self, address: u64) -> Result<Instruction<I>, Self::Error>
Retrieve the
Instruction at the given addressimpl<T: Copy + AsRef<[u8]>, B: Copy> Copy for Segment<T, B>
impl<T: PartialEq + AsRef<[u8]>, B: PartialEq> StructuralPartialEq for Segment<T, B>
Auto Trait Implementations§
impl<T, B> Freeze for Segment<T, B>
impl<T, B> RefUnwindSafe for Segment<T, B>where
T: RefUnwindSafe,
B: RefUnwindSafe,
impl<T, B> Send for Segment<T, B>
impl<T, B> Sync for Segment<T, B>
impl<T, B> Unpin for Segment<T, B>
impl<T, B> UnsafeUnpin for Segment<T, B>where
T: UnsafeUnpin,
B: UnsafeUnpin,
impl<T, B> UnwindSafe for Segment<T, B>where
T: UnwindSafe,
B: UnwindSafe,
Blanket Implementations§
Source§impl<T> Adaptable for T
impl<T> Adaptable for T
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
Converts
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> ⓘ
Converts
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