MapManager

Struct MapManager 

Source
pub struct MapManager { /* private fields */ }
Expand description

A manager struct that can read and write celeste maps.

Implementations§

Source§

impl MapManager

Source

pub fn default_parsers(&mut self)

Source§

impl MapManager

Source

pub fn new(reader: impl Read) -> Result<Self, MapReadError>

Creates a new MapManager reading in a celeste map from the passed reader

Source

pub fn parse_map(&self) -> Result<MapRoot, MapElementParsingError>

Parse the map passed in the constructor using any registered parsers when needed

Source

pub fn verbose_parse(&self) -> Result<MapRoot, MapElementParsingError>

Same as parse_map but when compiled with debug_assertions will print debug information about the parser

Source

pub fn encode_map(&mut self, name: impl ToString, root: &MapRoot)

Encode the map data back into a RawMap. The raw map is stored in the manager itself.

Source

pub fn add_parser<T: MapElement>(&mut self)

Allows the MapManager to parse a new type of MapElement.

All MapElement implementations in this crate can be added via MapManager::default_parsers.

This is used exclusively for parsing DynMapElements during calls to MapParser::parse_any_element any calls to MapParser::parse_element or MapParser::parse_all_elements will work even if a parser is never registered.

This generally should not be called with any Option<T>, as that will conflict with the parser for T. There is no place in the vanilla elements where having a DynMapElement be optional makes sense and so no Option<T> impls are registered by default.

Source

pub fn add_entity_parser<T: Entity>(&mut self)

Allows the MapManager to parse a new type of Entity

Acts the same as (add_parser)MapManager::add_parser but for entities

Source

pub fn map(&self) -> &RawMap

Gets a reference to the RawMap stored in the manager.

This is initialized in the constructor and modified in encode_map

Source

pub fn add_trigger_parser<T: Trigger>(&mut self)

Allows the MapManager to parse a new type of Trigger

Acts the same as (add_parser)MapManager::add_parser but for triggers

Source

pub fn write_map(&mut self, writer: &mut impl Write) -> Result<()>

Writes the stored map data as binary into the provided writer

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.