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: link.rs
    path of file: ./repos/grafbase/cli/crates/backend/src/api
    
    the code of the file until where you have to start completion: use super::{
    client::create_client,
    consts::API_URL,
    errors::ApiError,
    graphql::queries::viewer_for_link::{PersonalAccount, Viewer},
    types::{self, AccountWithProjects, ProjectMetadata},
    utils::has_project_linked,
};
use common::consts::PROJECT_METADATA_FILE;
use common::environment::Project;
use cynic::{http::ReqwestExt, QueryBuilder};
use std::iter;

/// # Errors
///
/// see [`ApiError`]
pub async fn project_link_validations() -> Result<(), ApiError> {
    if has_project_linked().await? {
        Err(ApiError::ProjectAlreadyLinked)
    } else {
        Ok(())
    }
}

/// # Errors
///
/// see [`ApiError`]
#[allow(clippy::module_name_repetitions)]
pub async fn get_viewer_data_for_link() -> Result<Vec<AccountWithProjects>, ApiError> {
    let client = create_client().await?;

    let query = Viewer::build(());

    let response = client.post(API_URL).run_graphql(query).await?;

    let response = response.data.expect("must exist");

    let viewer_response = response.viewer.ok_or(ApiError::UnauthorizedOrDeletedUser)?;

    let PersonalAccount {
        id,
        name,
        slug,
        projects,
    } = viewer_response
        .personal_account
        .ok_or(ApiError::IncorrectlyScopedToken)?;

    let personal_account_id = id;

    let personal_account = AccountWithProjects {
        id: personal_account_id.inner().to_owned(),
        name,
        slug,
        personal: true,
        projects: projects
            .nodes
            .into_iter()
            .map(|project| types::Project {
                id: project.id.into_inner(),
                slug: project.slug,
            })
            .collect(),
    };

    let accounts = iter::o
    
pub async fn get_viewer_data_for_link() -> Result<Vec<AccountWithProjects>, ApiError> {
    let client = create_client().await?;

    let query = Viewer::build(());

    let response = client.post(API_URL).run_graphql(query).await?;

    let response = response.data.expect("must exist");

    let viewer_response = response.viewer.ok_or(ApiError::UnauthorizedOrDeletedUser)?;

    let PersonalAccount {
        id,
        name,
        slug,
        projects,
    } = viewer_response
        .personal_account
        .ok_or(ApiError::IncorrectlyScopedToken)?;

    let personal_account_id = id;

    let personal_account = AccountWithProjects {
        id: personal_account_id.inner().to_owned(),
        name,
        slug,
        personal: true,
        projects: projects
            .nodes
            .into_iter()
            .map(|project| types::Project {
                id: project.id.into_inner(),
                slug: project.slug,
            })
            .collect(),
    };

    let accounts = iter::once(personal_account)
        .chain(viewer_response.organizations.nodes.iter().map(|organization| {
            AccountWithProjects {
                id: organization.id.inner().to_owned(),
                name: organization.name.clone(),
                slug: organization.slug.clone(),
                personal: false,
                projects: organization
                    .projects
                    .nodes
                    .iter()
                    .cloned()
                    .map(|project| types::Project {
                        id: project.id.into_inner(),
                        slug: project.slug,
                    })
                    .collect(),
            }
        }))
        .collect();

    Ok(accounts)
}