pub struct SnapshotDict {
pub version: u32,
pub time: f64,
pub gravity: [f64; 3],
pub bodies: Vec<BodyDict>,
pub n_contacts: usize,
pub description: Option<String>,
}Expand description
A Python-dict-compatible representation of a SimulationSnapshot.
The to_dict_json method returns a JSON string structured like a Python dict
that the Python side can eval() or json.loads() directly.
Fields§
§version: u32Snapshot version.
time: f64Simulation time.
gravity: [f64; 3]Gravity as list.
bodies: Vec<BodyDict>Body states as list of dicts.
n_contacts: usizeNumber of contacts.
description: Option<String>Optional description.
Implementations§
Source§impl SnapshotDict
impl SnapshotDict
Sourcepub fn from_snapshot(snap: &SimulationSnapshot) -> Self
pub fn from_snapshot(snap: &SimulationSnapshot) -> Self
Build from a SimulationSnapshot.
Sourcepub fn to_snapshot(&self) -> SimulationSnapshot
pub fn to_snapshot(&self) -> SimulationSnapshot
Convert back to SimulationSnapshot.
Sourcepub fn to_dict_json(&self) -> String
pub fn to_dict_json(&self) -> String
Serialize to JSON string (like Python’s json.dumps).
Sourcepub fn from_dict_json(json: &str) -> Result<Self, Error>
pub fn from_dict_json(json: &str) -> Result<Self, Error>
Deserialize from JSON string.
Trait Implementations§
Source§impl Clone for SnapshotDict
impl Clone for SnapshotDict
Source§fn clone(&self) -> SnapshotDict
fn clone(&self) -> SnapshotDict
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SnapshotDict
impl Debug for SnapshotDict
Source§impl<'de> Deserialize<'de> for SnapshotDict
impl<'de> Deserialize<'de> for SnapshotDict
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for SnapshotDict
impl RefUnwindSafe for SnapshotDict
impl Send for SnapshotDict
impl Sync for SnapshotDict
impl Unpin for SnapshotDict
impl UnsafeUnpin for SnapshotDict
impl UnwindSafe for SnapshotDict
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.