pub struct StartposLayout { /* private fields */ }Expand description
Layouts of every record path of a startpos.
Implementations§
Source§impl StartposLayout
impl StartposLayout
Sourcepub fn from_esfs(
startposes: impl IntoIterator<Item = Result<ESF>>,
) -> Result<Self>
pub fn from_esfs( startposes: impl IntoIterator<Item = Result<ESF>>, ) -> Result<Self>
Extracts the layouts of every record of several startposes, as if their records were in a single one: defaults are the most common values across all of them. Startposes are taken one at a time, so only one needs to be in memory.
§Arguments
startposes- Game-built startposes of the same game, or the errors getting them.
§Errors
Returns the first error getting a startpos, or an error if a root isn’t a record.
Sourcepub fn with_fallback(self, fallback: &StartposLayout) -> Self
pub fn with_fallback(self, fallback: &StartposLayout) -> Self
Adds what this layout lacks from another one, like records a campaign never uses from a layout merged from all the game’s campaigns:
- Paths it doesn’t have, and paths it has only seen empty (arrays without items).
- Slots its records lack, after the slot they follow in the other layout. They’re optional and start out of built records, so records only have them when a generator sets them.
Everything this layout has keeps its own layout and defaults.
Sourcepub fn record(&self, path: &str) -> Option<&RecordLayout>
pub fn record(&self, path: &str) -> Option<&RecordLayout>
Returns the layout of a record path.
Sourcepub fn builder(&self, path: &str) -> Result<RecordBuilder<'_>>
pub fn builder(&self, path: &str) -> Result<RecordBuilder<'_>>
Sourcepub fn default_record(&self, path: &str) -> Result<RecordNode>
pub fn default_record(&self, path: &str) -> Result<RecordNode>
Builds a record with every slot at its default.
§Errors
Returns an error if the layout lacks the path or one of its child records.
Sourcepub fn read<'a>(
&'a self,
path: &str,
record: &'a RecordNode,
) -> Result<Vec<GroupView<'a>>>
pub fn read<'a>( &'a self, path: &str, record: &'a RecordNode, ) -> Result<Vec<GroupView<'a>>>
Sourcepub fn read_single<'a>(
&'a self,
path: &str,
record: &'a RecordNode,
) -> Result<GroupView<'a>>
pub fn read_single<'a>( &'a self, path: &str, record: &'a RecordNode, ) -> Result<GroupView<'a>>
Sourcepub fn read_items<'a>(
&'a self,
array_path: &str,
parent: &GroupView<'a>,
array_key: &str,
item_key: &str,
) -> Result<Vec<(GroupView<'a>, GroupView<'a>)>>
pub fn read_items<'a>( &'a self, array_path: &str, parent: &GroupView<'a>, array_key: &str, item_key: &str, ) -> Result<Vec<(GroupView<'a>, GroupView<'a>)>>
Reads the items of an array record child of a group: each array group, with its item record’s only group.
§Arguments
array_path- Path of the array record.parent- The group holding the array.array_key- Key of the array record in the parent.item_key- Key of the item record in each array group.
§Returns
The array group and the item’s group of each item. None if the parent lacks the array.
§Errors
Returns an error if a record doesn’t fit its layout, or an array group lacks its item.
Sourcepub fn raw_record(
&self,
path: &str,
children: Vec<NodeType>,
) -> Result<RecordNode>
pub fn raw_record( &self, path: &str, children: Vec<NodeType>, ) -> Result<RecordNode>
Builds a record with the given children as its only group, as they are. For records whose shape varies too much for slots, like lists of buildings.
§Errors
Returns an error if the layout has no such path.
Trait Implementations§
Source§impl Clone for StartposLayout
impl Clone for StartposLayout
Source§fn clone(&self) -> StartposLayout
fn clone(&self) -> StartposLayout
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StartposLayout
impl Debug for StartposLayout
Source§impl Default for StartposLayout
impl Default for StartposLayout
Source§fn default() -> StartposLayout
fn default() -> StartposLayout
Source§impl<'de> Deserialize<'de> for StartposLayout
impl<'de> Deserialize<'de> for StartposLayout
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for StartposLayout
impl PartialEq for StartposLayout
Source§impl Serialize for StartposLayout
impl Serialize for StartposLayout
impl StructuralPartialEq for StartposLayout
Auto Trait Implementations§
impl Freeze for StartposLayout
impl RefUnwindSafe for StartposLayout
impl Send for StartposLayout
impl Sync for StartposLayout
impl Unpin for StartposLayout
impl UnsafeUnpin for StartposLayout
impl UnwindSafe for StartposLayout
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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 moreimpl<T> MaybeSend for T
impl<T> MaybeSync for T
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().impl<T> Scalar for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.