Skip to main content

openstack_keystone_distributed_storage/proto_impl/
impl_log_id.rs

1// Licensed under the Apache License, Version 2.0 (the "License");
2// you may not use this file except in compliance with the License.
3// You may obtain a copy of the License at
4//
5//     http://www.apache.org/licenses/LICENSE-2.0
6//
7// Unless required by applicable law or agreed to in writing, software
8// distributed under the License is distributed on an "AS IS" BASIS,
9// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10// See the License for the specific language governing permissions and
11// limitations under the License.
12//
13// SPDX-License-Identifier: Apache-2.0
14use crate::pb;
15use crate::types::LogId;
16
17impl From<LogId> for pb::raft::LogId {
18    fn from(log_id: LogId) -> Self {
19        pb::raft::LogId {
20            term: *log_id.committed_leader_id(),
21            index: log_id.index(),
22        }
23    }
24}
25
26impl From<pb::raft::LogId> for LogId {
27    fn from(proto_log_id: pb::raft::LogId) -> Self {
28        LogId::new(proto_log_id.term, proto_log_id.index)
29    }
30}