FSTLocalSerializer.h 2.6 KB

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