Serializable.h 902 B

123456789101112131415161718192021222324252627
  1. /*
  2. * Copyright (c) 2024, Kenneth Myhra <kennethmyhra@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibJS/Runtime/Realm.h>
  8. #include <LibWeb/HTML/StructuredSerialize.h>
  9. namespace Web::Bindings {
  10. // https://html.spec.whatwg.org/multipage/structured-data.html#serializable-objects
  11. class Serializable {
  12. public:
  13. virtual ~Serializable() = default;
  14. virtual StringView interface_name() const = 0;
  15. // https://html.spec.whatwg.org/multipage/structured-data.html#serialization-steps
  16. virtual WebIDL::ExceptionOr<void> serialization_steps(HTML::SerializationRecord&, bool for_storage, HTML::SerializationMemory&) = 0;
  17. // https://html.spec.whatwg.org/multipage/structured-data.html#deserialization-steps
  18. virtual WebIDL::ExceptionOr<void> deserialization_steps(ReadonlySpan<u32> const&, size_t& position, HTML::DeserializationMemory&) = 0;
  19. };
  20. }