]> git.proxmox.com Git - proxmox-backup.git/blobdiff - pbs-api-types/src/userid.rs
update to first proxmox crate split
[proxmox-backup.git] / pbs-api-types / src / userid.rs
index 8418f13ecebe2e0c50bbe4cd68c9523588b51099..8c58da2e0f58a9f3ac9493d249fdd69b4c39960f 100644 (file)
@@ -29,9 +29,9 @@ use anyhow::{bail, format_err, Error};
 use lazy_static::lazy_static;
 use serde::{Deserialize, Serialize};
 
-use proxmox::api::api;
-use proxmox::api::schema::{ApiStringFormat, Schema, StringSchema, Updatable};
-use proxmox::const_regex;
+use proxmox_schema::{
+    api, const_regex, ApiStringFormat, ApiType, Schema, StringSchema, UpdaterType,
+};
 
 // we only allow a limited set of characters
 // colon is not allowed, because we store usernames in
@@ -397,25 +397,21 @@ impl<'a> TryFrom<&'a str> for &'a TokennameRef {
 }
 
 /// A complete user id consisting of a user name and a realm
-#[derive(Clone, Debug, PartialEq, Eq, Hash)]
+#[derive(Clone, Debug, PartialEq, Eq, Hash, UpdaterType)]
 pub struct Userid {
     data: String,
     name_len: usize,
 }
 
-impl Updatable for Userid {
-    type Updater = Option<Userid>;
-
-    const UPDATER_IS_OPTION: bool = true;
-}
-
-impl Userid {
-    pub const API_SCHEMA: Schema = StringSchema::new("User ID")
+impl ApiType for Userid {
+    const API_SCHEMA: Schema = StringSchema::new("User ID")
         .format(&PROXMOX_USER_ID_FORMAT)
         .min_length(3)
         .max_length(64)
         .schema();
+}
 
+impl Userid {
     const fn new(data: String, name_len: usize) -> Self {
         Self { data, name_len }
     }
@@ -532,19 +528,21 @@ impl PartialEq<String> for Userid {
 }
 
 /// A complete authentication id consisting of a user id and an optional token name.
-#[derive(Clone, Debug, Eq, PartialEq, Hash)]
+#[derive(Clone, Debug, Eq, PartialEq, Hash, UpdaterType)]
 pub struct Authid {
     user: Userid,
     tokenname: Option<Tokenname>
 }
 
-impl Authid {
-    pub const API_SCHEMA: Schema = StringSchema::new("Authentication ID")
+impl ApiType for Authid {
+    const API_SCHEMA: Schema = StringSchema::new("Authentication ID")
         .format(&PROXMOX_AUTH_ID_FORMAT)
         .min_length(3)
         .max_length(64)
         .schema();
+}
 
+impl Authid {
     const fn new(user: Userid, tokenname: Option<Tokenname>) -> Self {
         Self { user, tokenname }
     }