refactor: split large modules and normalize rust layout
This commit is contained in:
42
server-rs/crates/spacetime-client/src/mapper/auth.rs
Normal file
42
server-rs/crates/spacetime-client/src/mapper/auth.rs
Normal file
@@ -0,0 +1,42 @@
|
||||
use super::*;
|
||||
|
||||
pub(crate) fn map_auth_store_snapshot_procedure_result(
|
||||
result: AuthStoreSnapshotProcedureResult,
|
||||
) -> Result<AuthStoreSnapshotRecord, SpacetimeClientError> {
|
||||
if !result.ok {
|
||||
return Err(SpacetimeClientError::procedure_failed(result.error_message));
|
||||
}
|
||||
|
||||
let record = result
|
||||
.record
|
||||
.ok_or_else(|| SpacetimeClientError::missing_snapshot("认证快照"))?;
|
||||
|
||||
Ok(map_auth_store_snapshot_record(record))
|
||||
}
|
||||
|
||||
pub(crate) fn map_auth_store_snapshot_record(
|
||||
record: crate::module_bindings::AuthStoreSnapshotRecord,
|
||||
) -> crate::AuthStoreSnapshotRecord {
|
||||
crate::AuthStoreSnapshotRecord {
|
||||
snapshot_json: record.snapshot_json,
|
||||
updated_at_micros: record.updated_at_micros,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn map_auth_store_snapshot_import_procedure_result(
|
||||
result: AuthStoreSnapshotImportProcedureResult,
|
||||
) -> Result<AuthStoreSnapshotImportRecord, SpacetimeClientError> {
|
||||
if !result.ok {
|
||||
return Err(SpacetimeClientError::procedure_failed(result.error_message));
|
||||
}
|
||||
|
||||
let record = result
|
||||
.record
|
||||
.ok_or_else(|| SpacetimeClientError::missing_snapshot("认证快照导入结果"))?;
|
||||
|
||||
Ok(AuthStoreSnapshotImportRecord {
|
||||
imported_user_count: record.imported_user_count,
|
||||
imported_identity_count: record.imported_identity_count,
|
||||
imported_refresh_session_count: record.imported_refresh_session_count,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user