mz_repr/
antichain.rs

1// Copyright Materialize, Inc. and contributors. All rights reserved.
2//
3// Use of this software is governed by the Business Source License
4// included in the LICENSE file.
5//
6// As of the Change Date specified in that file, in accordance with
7// the Business Source License, use of this software will be governed
8// by the Apache License, Version 2.0.
9
10use mz_proto::{RustType, TryFromProtoError};
11use timely::progress::Antichain;
12
13use crate::Timestamp;
14
15include!(concat!(env!("OUT_DIR"), "/mz_repr.antichain.rs"));
16
17impl RustType<ProtoU64Antichain> for Antichain<Timestamp> {
18    fn into_proto(&self) -> ProtoU64Antichain {
19        ProtoU64Antichain {
20            elements: self.elements().iter().map(Into::into).collect(),
21        }
22    }
23
24    fn from_proto(proto: ProtoU64Antichain) -> Result<Self, TryFromProtoError> {
25        Ok(Antichain::from_iter(
26            proto.elements.into_iter().map(Timestamp::from),
27        ))
28    }
29}