pub struct CommandLists<'a> { /* private fields */ }Expand description
Finds every event command list under a file root, without allocating.
What makes the core tier usable for real work. liblcf cannot express it: reaching one map’s
commands means parsing the whole rpg::Map into std::vectors, copying every string. Here the
traversal is spans into the caller’s buffer, so it runs on a microcontroller against a
memory-mapped file.
let mut sink = NullSink;
let mut ctx = Ctx::new(Engine::R2K, &mut sink);
let mut lists = CommandLists::in_map(map_body, 0, &mut ctx);
while let Some(list) = lists.next(&mut ctx) {
let mut commands = list.commands();
while let Some(command) = commands.next(&mut ctx) {
let _ = (command.code, command.string);
}
}Implementations§
Source§impl<'a> CommandLists<'a>
impl<'a> CommandLists<'a>
Sourcepub fn in_map(body: &'a [u8], base: u32, ctx: &mut Ctx<'_>) -> Self
pub fn in_map(body: &'a [u8], base: u32, ctx: &mut Ctx<'_>) -> Self
Every command list in a map, from its root chunk stream.
body is the map’s chunk stream: what load_map parses, minus the
file header.
Sourcepub fn in_common_events(body: &'a [u8], base: u32, ctx: &mut Ctx<'_>) -> Self
pub fn in_common_events(body: &'a [u8], base: u32, ctx: &mut Ctx<'_>) -> Self
Every common event’s command list, from a database’s chunk stream.
Sourcepub fn in_battle_events(body: &'a [u8], base: u32, ctx: &mut Ctx<'_>) -> Self
pub fn in_battle_events(body: &'a [u8], base: u32, ctx: &mut Ctx<'_>) -> Self
Every troop page’s command list, from a database’s chunk stream.
Sourcepub fn next(&mut self, ctx: &mut Ctx<'_>) -> Option<CommandListAt<'a>>
pub fn next(&mut self, ctx: &mut Ctx<'_>) -> Option<CommandListAt<'a>>
Yield the next command list.
Trait Implementations§
Source§impl<'a> Clone for CommandLists<'a>
impl<'a> Clone for CommandLists<'a>
Auto Trait Implementations§
impl<'a> Freeze for CommandLists<'a>
impl<'a> RefUnwindSafe for CommandLists<'a>
impl<'a> Send for CommandLists<'a>
impl<'a> Sync for CommandLists<'a>
impl<'a> Unpin for CommandLists<'a>
impl<'a> UnsafeUnpin for CommandLists<'a>
impl<'a> UnwindSafe for CommandLists<'a>
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
Mutably borrows from an owned value. Read more