FSTLocalSerializer.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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/model/snapshot_version.h"
  18. @class FSTMaybeDocument;
  19. @class FSTMutationBatch;
  20. @class FSTQueryData;
  21. @class FSTSerializerBeta;
  22. @class FSTPBMaybeDocument;
  23. @class FSTPBTarget;
  24. @class FSTPBWriteBatch;
  25. @class GPBTimestamp;
  26. NS_ASSUME_NONNULL_BEGIN
  27. /**
  28. * Serializer for values stored in the LocalStore.
  29. *
  30. * Note that FSTLocalSerializer currently delegates to the serializer for the Firestore v1 RPC
  31. * protocol to save implementation time and code duplication. We'll need to revisit this when the
  32. * RPC protocol we use diverges from local storage.
  33. */
  34. @interface FSTLocalSerializer : NSObject
  35. - (instancetype)initWithRemoteSerializer:(FSTSerializerBeta *)remoteSerializer;
  36. - (instancetype)init NS_UNAVAILABLE;
  37. /** Encodes an FSTMaybeDocument model to the equivalent protocol buffer for local storage. */
  38. - (FSTPBMaybeDocument *)encodedMaybeDocument:(FSTMaybeDocument *)document;
  39. /** Decodes an FSTPBMaybeDocument proto to the equivalent model. */
  40. - (FSTMaybeDocument *)decodedMaybeDocument:(FSTPBMaybeDocument *)proto;
  41. /** Encodes an FSTMutationBatch model for local storage in the mutation queue. */
  42. - (FSTPBWriteBatch *)encodedMutationBatch:(FSTMutationBatch *)batch;
  43. /** Decodes an FSTPBWriteBatch proto into a MutationBatch model. */
  44. - (FSTMutationBatch *)decodedMutationBatch:(FSTPBWriteBatch *)batch;
  45. /** Encodes an FSTQueryData model for local storage in the query cache. */
  46. - (FSTPBTarget *)encodedQueryData:(FSTQueryData *)queryData;
  47. /** Decodes an FSTPBTarget proto from local storage into an FSTQueryData model. */
  48. - (FSTQueryData *)decodedQueryData:(FSTPBTarget *)target;
  49. /** Encodes a SnapshotVersion model into a GPBTimestamp proto. */
  50. - (GPBTimestamp *)encodedVersion:(const firebase::firestore::model::SnapshotVersion &)version;
  51. /** Decodes a GPBTimestamp proto into a SnapshotVersion model. */
  52. - (firebase::firestore::model::SnapshotVersion)decodedVersion:(GPBTimestamp *)version;
  53. @end
  54. NS_ASSUME_NONNULL_END