Serialization & snapshot
========================

The :class:`~rapier3d.PhysicsWorld` umbrella supports binary snapshots
of a full world via :meth:`~rapier3d.PhysicsWorld.snapshot` and
:meth:`~rapier3d.PhysicsWorld.restore`. Every value-style pyclass
(``RigidBody``, ``Collider``, ``Vec3``, …) also supports
``to_bytes()`` / ``from_bytes(...)`` and Python's ``pickle`` protocol.

Pickle is wired up via the ``__reduce__`` protocol on each pyclass so
that round-tripping through ``pickle.dumps`` / ``pickle.loads`` (or
``copy.deepcopy``) reconstructs equivalent objects.

.. currentmodule:: rapier3d

Snapshot API
------------

The snapshot methods live on :class:`PhysicsWorld` itself — see
:doc:`world` for the full class:

.. autoclass:: PhysicsWorld
   :no-index:
   :members: snapshot, restore

Errors
------

:meth:`~rapier3d.PhysicsWorld.restore`, ``from_bytes(...)``, and the
``pickle.loads`` / ``copy.deepcopy`` paths raise
:class:`~rapier3d.SerializationError` (a subclass of
:class:`~rapier3d.RapierError`) on malformed or truncated input. See
:doc:`errors`.
