use core::ffi::c_void;
use crate::abi::{Header, Status, Str};
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct MigrationStep {
pub kind: u32,
pub from: Str,
pub to: Str,
pub from_guid: [u8; 16],
pub to_guid: [u8; 16],
}
impl MigrationStep {
pub const RENAME_SETTING: u32 = 1;
pub const MAP_SETTING: u32 = 2;
pub const REMOVE_SETTING: u32 = 3;
pub const RENAME_STORE: u32 = 4;
pub const MAP_STORE: u32 = 5;
pub const RENAME_CONTENT: u32 = 6;
pub const TAKE_SETTING: u32 = 7;
}
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct Migration {
pub id: Str,
pub steps: *const MigrationStep,
pub count: u32,
}
pub type MigrateFn = unsafe extern "system" fn(
user: *mut c_void,
migration: u32,
step: u32,
input: Str,
out: *mut Str,
) -> Status;
#[repr(C)]
#[derive(Clone, Copy, Debug, bytemuck::Zeroable)]
pub struct MigrationSet {
pub header: Header,
pub migrations: *const Migration,
pub count: u32,
pub map: Option<
unsafe extern "system" fn(
user: *mut c_void,
migration: u32,
step: u32,
input: Str,
out: *mut Str,
) -> Status,
>,
pub user: *mut c_void,
}
impl_headed!(MigrationSet);