pub async fn create_user<'a>(
virtual_file_system: &'a VirtualFileSystem<'a>,
user_name: &str,
password: &str,
primary_group: GroupIdentifier,
user_identifier: Option<UserIdentifier>,
) -> Result<UserIdentifier>
Expand description
Creates a new user account with the specified parameters.
This function creates a new user in the system by:
- Generating a new user identifier (if not provided)
- Adding the user to the Users manager
- Generating a random salt and hashing the password
- Creating the user file with all user data
§Arguments
Virtual_file_system
- Reference to the virtual file systemUser_name
- Username for the new accountPassword
- Plain text password for the new accountPrimary_group
- Primary group identifier for the userUser_identifier
- Optional specific user identifier (auto-generated if None)
§Returns
Returns Ok(User_identifier_type)
with the new user’s identifier,
or an appropriate error if creation fails.
§Errors
This function can fail for various reasons including:
- User identifier generation or assignment failures
- File system operations (directory creation, file writing)
- Users manager operations (adding user)
- Random salt generation failures