Skip to content

Commit 019820b

Browse files
committed
refactor: implement from<EntityId> for pb::EntityIdSet for convenience
1 parent fd8bd8c commit 019820b

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

shared/src/types/entity.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,26 @@ impl TryFrom<pb::EntityIdSet> for EntityId {
159159
}
160160
}
161161

162+
#[cfg(feature = "grpc")]
163+
impl From<EntityId> for pb::EntityIdSet {
164+
fn from(value: EntityId) -> Self {
165+
match value {
166+
EntityId::Alias(a) => pb::EntityIdSet {
167+
alias: Some(a.into()),
168+
..Default::default()
169+
},
170+
EntityId::LegacyID(id) => pb::EntityIdSet {
171+
legacy_id: Some(id.into()),
172+
..Default::default()
173+
},
174+
EntityId::Uid(uid) => pb::EntityIdSet {
175+
uid: Some(uid),
176+
..Default::default()
177+
},
178+
}
179+
}
180+
}
181+
162182
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
163183
pub struct EntityIdSet {
164184
pub uid: Uid,

0 commit comments

Comments
 (0)