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: nodeinfo.rs
    path of file: ./repos/lemmy/crates/routes/src
    
    the code of the file until where you have to start completion: use actix_web::{error::ErrorBadRequest, web, Error, HttpResponse, Result};
use anyhow::anyhow;
use lemmy_api_common::context::LemmyContext;
use lemmy_db_sche
    
async fn node_info(context: web::Data<LemmyContext>) -> Result<HttpResponse, Error> {
  let site_view = SiteView::read_local(&mut context.pool())
    .await
    .map_err(|_| ErrorBadRequest(LemmyError::from(anyhow!("not_found"))))?;

  let protocols = if site_view.local_site.federation_enabled {
    Some(vec!["activitypub".to_string()])
  } else {
    None
  };
  // Since there are 3 registration options,
  // we need to set open_registrations as true if RegistrationMode is not Closed.
  let open_registrations = Some(site_view.local_site.registration_mode != RegistrationMode::Closed);
  let json = NodeInfo {
    version: Some("2.0".to_string()),
    software: Some(NodeInfoSoftware {
      name: Some("lemmy".to_string()),
      version: Some(version::VERSION.to_string()),
    }),
    protocols,
    usage: Some(NodeInfoUsage {
      users: Some(NodeInfoUsers {
        total: Some(site_view.counts.users),
        active_halfyear: Some(site_view.counts.users_active_half_year),
        active_month: Some(site_view.counts.users_active_month),
      }),
      local_posts: Some(site_view.counts.posts),
      local_comments: Some(site_view.counts.comments),
    }),
    open_registrations,
  };

  Ok(HttpResponse::Ok().json(json))
}