FSTLocalSerializer.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. #include "Firestore/core/src/firebase/firestore/local/query_data.h"
  18. #include "Firestore/core/src/firebase/firestore/model/maybe_document.h"
  19. #include "Firestore/core/src/firebase/firestore/model/mutation_batch.h"
  20. #include "Firestore/core/src/firebase/firestore/model/snapshot_version.h"
  21. @class FSTSerializerBeta;
  22. @class FSTPBMaybeDocument;
  23. @class FSTPBTarget;
  24. @class FSTPBWriteBatch;
  25. @class GPBTimestamp;
  26. namespace local = firebase::firestore::local;
  27. namespace model = firebase::firestore::model;
  28. NS_ASSUME_NONNULL_BEGIN
  29. /**
  30. * Serializer for values stored in the LocalStore.
  31. *
  32. * Note that FSTLocalSerializer currently delegates to the serializer for the Firestore v1 RPC
  33. * protocol to save implementation time and code duplication. We'll need to revisit this when the
  34. * RPC protocol we use diverges from local storage.
  35. */
  36. @interface FSTLocalSerializer : NSObject
  37. - (instancetype)initWithRemoteSerializer:(FSTSerializerBeta *)remoteSerializer;
  38. - (instancetype)init NS_UNAVAILABLE;
  39. /** Encodes a MaybeDocument model to the equivalent protocol buffer for local storage. */
  40. - (FSTPBMaybeDocument *)encodedMaybeDocument:(const model::MaybeDocument &)document;
  41. /** Decodes an FSTPBMaybeDocument proto to the equivalent model. */
  42. - (model::MaybeDocument)decodedMaybeDocument:(FSTPBMaybeDocument *)proto;
  43. /** Encodes an MutationBatch model for local storage in the mutation queue. */
  44. - (FSTPBWriteBatch *)encodedMutationBatch:(const model::MutationBatch &)batch;
  45. /** Decodes an FSTPBWriteBatch proto into a MutationBatch model. */
  46. - (model::MutationBatch)decodedMutationBatch:(FSTPBWriteBatch *)batch;
  47. /** Encodes a QueryData model for local storage in the query cache. */
  48. - (FSTPBTarget *)encodedQueryData:(const local::QueryData &)queryData;
  49. /** Decodes an FSTPBTarget proto from local storage into a QueryData model. */
  50. - (local::QueryData)decodedQueryData:(FSTPBTarget *)target;
  51. /** Encodes a SnapshotVersion model into a GPBTimestamp proto. */
  52. - (GPBTimestamp *)encodedVersion:(const model::SnapshotVersion &)version;
  53. /** Decodes a GPBTimestamp proto into a SnapshotVersion model. */
  54. - (model::SnapshotVersion)decodedVersion:(GPBTimestamp *)version;
  55. @end
  56. NS_ASSUME_NONNULL_END