You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: account.rs
    path of file: ./repos/habitat/components/win-users/src
    
    the code of the file until where you have to start completion: use std::{env,
          io::Error,
          ptr::{null,
                null_mut}};

use log::{debug,
          error};
use widestring::WideCString;
use winapi::{shared::{minwindef::{BOOL,
                                  LPDWORD},
                      ntdef::LPCWSTR,
                      winerror::*},
             um::{winbase::LookupAccountSidW,
                  winnt::{PSID,
                          PSID_NAME_USE,
                          SID_NAME_USE}}};

use super::sid::Sid;

extern "system" {
    fn LookupAccountNameW(lpSystemName: LPCWSTR,
                          lpAccountName: LPCWSTR,
                          Sid: PSID,
                          cbSid: LPDWORD,
                          ReferencedDomainName: LPCWSTR,
                          cchReferencedDomainName: LPDWORD,
                          peUse: PSID_NAME_USE)
                          -> BOOL;
}

pub struct Account {
    pub name:         String,
    pub system_name:  Option<String>,
    pub domain:       String,
    pub account_type: SID_NAME_USE,
    pub sid:          Sid,
}

impl Account {
    pub fn from_name(name: &str) -> Option<Account> { lookup_account(name, None) }

    pub fn from_name_and_system(name: &str, system_name: &str) -> Option<Account> {
        lookup_account(name, Some(system_name.to_string()))
    }

    pub fn from_sid(sid: &str) -> Option<Account> {
        #[allow(clippy::question_mark)]
        let sid = if let Ok(sid) = Sid::from_str(sid) {
            sid
        } else {
            return None;
        };
        let mut name_size: u32 = 0
    
    pub fn from_name(name: &str) -> Option<Account> { lookup_account(name, None) }

    pub fn from_name_and_system(name: &str, system_name: &str) -> Option<Account> {
        lookup_account(name, Some(system_name.to_string()))
    }

    pub fn from_sid(sid: &str) -> Option<Account> {
        #[allow(clippy::question_mark)]
        let sid = if let Ok(sid) = Sid::from_str(sid) {
            sid
        } else {
            return None;
        };
        let mut name_size: u32 = 0;
        let mut domain_size: u32 = 0;
        let ret = unsafe {
            LookupAccountSidW(null(),
                              sid.raw.as_ptr() as *mut _,
                              null_mut(),
                              &mut name_size as LPDWORD,
                              null_mut(),
                              &mut domain_size as LPDWORD,
                              null_mut())
        };
        if ret == 0 {
            match Error::last_os_error().raw_os_error().unwrap() as u32 {
                ERROR_INSUFFICIENT_BUFFER => {}
                ERROR_NONE_MAPPED => return None,
                _ => {
                    debug!("Error while looking up account for {}: {}",
                           sid.to_string().expect("to convert sid to string"),
                           Error::last_os_error());
                    return None;
                }
            }
        }

        let mut name: Vec<u16> = Vec::with_capacity(name_size as usize);
        let mut domain: Vec<u16> = Vec::with_capacity(domain_size as usize);
        let mut sid_type = 0;

        let ret = unsafe {
            LookupAccountSidW(null(),
                              sid.raw.as_ptr() as *mut _,
                              name.as_mut_ptr(),
                              &mut name_size as LPDWORD,
                              domain.as_mut_ptr(),
                              &mut domain_size as LPDWORD,
                              &mut sid_type as PSID_NAME_USE)
        };
        if ret == 0 {
            error!("Failed to retrieve name for {}: {}",
                   sid.to_string().expect("to convert sid to string"),
                   Error::last_os_error());
            return None;
        }
        unsafe {
            name.set_len(name_size as usize);
            domain.set_len(domain_size as usize);
        }
        let name = WideCString::from_vec(name).expect("valid name widestring")
                                              .to_string_lossy();
        let domain = WideCString::from_vec(domain).expect("valid domain widestring")
                                                  .to_string_lossy();
        Some(Account { name,
                       system_name: None,
                       domain,
                       account_type: sid_type,
                       sid })
    }
}