matrix-sdk: Implement EncodeKey for EventType

master
Kévin Commaille 2021-04-27 10:57:38 +02:00
parent 3f2c5d22b6
commit f6c4fdde7d
No known key found for this signature in database
GPG Key ID: 296D60AE1E61661C
1 changed files with 8 additions and 2 deletions

View File

@ -134,6 +134,12 @@ impl EncodeKey for (&str, &str, &str) {
}
}
impl EncodeKey for EventType {
fn encode(&self) -> Vec<u8> {
self.as_str().encode()
}
}
#[derive(Clone)]
pub struct SledStore {
path: Option<PathBuf>,
@ -495,7 +501,7 @@ impl SledStore {
) -> Result<Option<AnySyncStateEvent>> {
Ok(self
.room_state
.get((room_id.as_str(), event_type.to_string().as_str(), state_key).encode())?
.get((room_id.as_str(), event_type.as_str(), state_key).encode())?
.map(|e| self.deserialize_event(&e))
.transpose()?)
}
@ -594,7 +600,7 @@ impl SledStore {
) -> Result<Option<AnyBasicEvent>> {
Ok(self
.account_data
.get(event_type.to_string().as_str().encode())?
.get(event_type.encode())?
.map(|m| self.deserialize_event(&m))
.transpose()?)
}