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: winpipe.rs
    path of file: ./repos/deno/ext/io
    
    the code of the file until where you have to start completion: // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
use rand::thread_rng;
use rand::RngCore;
use std::io;
use std::os::windows::io::RawHandle;
use std::sync::atomic::AtomicU32;
use std::sync::
    
fn create_named_pipe_inner() -> io::Result<(RawHandle, RawHandle)> {
  static NEXT_ID: AtomicU32 = AtomicU32::new(0);
  // Create an extremely-likely-unique pipe name from randomness, identity and a serial counter.
  let pipe_name = format!(
    r#"\\.\pipe\deno_pipe_{:x}.{:x}.{:x}\0"#,
    thread_rng().next_u64(),
    std::process::id(),
    NEXT_ID.fetch_add(1, Ordering::SeqCst),
  );

  // Create security attributes to make the pipe handles non-inheritable
  let mut security_attributes = SECURITY_ATTRIBUTES {
    nLength: std::mem::size_of::<SECURITY_ATTRIBUTES>() as DWORD,
    lpSecurityDescriptor: std::ptr::null_mut(),
    bInheritHandle: 0,
  };

  // SAFETY: Create the pipe server with non-inheritable handle
  let server_handle = unsafe {
    CreateNamedPipeA(
      pipe_name.as_ptr() as *const i8,
      PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED | FILE_FLAG_FIRST_PIPE_INSTANCE,
      // Read and write bytes, not messages
      PIPE_TYPE_BYTE | PIPE_READMODE_BYTE,
      // The maximum number of instances that can be created for this pipe.
      1,
      // 4kB buffer sizes
      4096,
      4096,
      // "The default time-out value, in milliseconds, if the WaitNamedPipe function specifies NMPWAIT_USE_DEFAULT_WAIT.
      // Each instance of a named pipe must specify the same value. A value of zero will result in a default time-out of
      // 50 milliseconds."
      0,
      &mut security_attributes,
    )
  };

  if server_handle == INVALID_HANDLE_VALUE {
    // This should not happen, so we would like to get some better diagnostics here.
    // SAFETY: Printing last error for diagnostics
    unsafe {
      eprintln!(
        "*** Unexpected server pipe failure '{pipe_name:?}': {:x}",
        GetLastError()
      );
    }
    return Err(io::Error::last_os_error());
  }

  // The pipe might not be ready yet in rare cases, so we loop for a bit
  for i in 0..10 {
    // SAFETY: Create the pipe client with non-inheritable handle
    let client_handle = unsafe {
      CreateFileA(
        pipe_name.as_ptr() as *const i8,
        GENERIC_READ | GENERIC_WRITE,
        0,
        &mut security_attributes,
        OPEN_EXISTING,
        FILE_FLAG_OVERLAPPED,
        std::ptr::null_mut(),
      )
    };

    // There is a very rare case where the pipe is not ready to open. If we get `ERROR_PATH_NOT_FOUND`,
    // we spin and try again in 1-10ms.
    if client_handle == INVALID_HANDLE_VALUE {
      // SAFETY: Getting last error for diagnostics
      let error = unsafe { GetLastError() };
      if error == winapi::shared::winerror::ERROR_FILE_NOT_FOUND
        || error == winapi::shared::winerror::ERROR_PATH_NOT_FOUND
      {
        // Exponential backoff, but don't sleep longer than 10ms
        eprintln!(
          "*** Unexpected client pipe not found failure '{pipe_name:?}': {:x}",
          error
        );
        std::thread::sleep(Duration::from_millis(10.min(2_u64.pow(i) + 1)));
        continue;
      }

      // This should not happen, so we would like to get some better diagnostics here.
      eprintln!(
        "*** Unexpected client pipe failure '{pipe_name:?}': {:x}",
        error
      );
      let err = io::Error::last_os_error();
      // SAFETY: Close the handles if we failed
      unsafe {
        CloseHandle(server_handle);
      }
      return Err(err);
    }

    return Ok((server_handle, client_handle));
  }

  // We failed to open the pipe despite sleeping
  Err(std::io::ErrorKind::NotFound.into())
}