FSTLocalSerializer.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. @class FSTMaybeDocument;
  18. @class FSTMutationBatch;
  19. @class FSTQueryData;
  20. @class FSTSerializerBeta;
  21. @class FSTSnapshotVersion;
  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 v1beta1 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 an FSTSnapshotVersion model into a GPBTimestamp proto. */
  50. - (GPBTimestamp *)encodedVersion:(FSTSnapshotVersion *)version;
  51. /** Decodes a GPBTimestamp proto into a FSTSnapshotVersion model. */
  52. - (FSTSnapshotVersion *)decodedVersion:(GPBTimestamp *)version;
  53. @end
  54. NS_ASSUME_NONNULL_END