blob: 5ae1ff8d8da6963ab68349947eaea8fd9a3945da [file] [log] [blame]
// Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use crate::{Result, SessionId};
use fuchsia_zircon as zx;
use zx::AsHandleRef;
/// A universally unique id.
#[derive(Debug)]
pub struct Id {
id: SessionId,
// TODO(fxbug.dev/84729)
#[allow(unused)]
id_handle: zx::Event,
}
impl Id {
pub fn new() -> Result<Self> {
let id_handle = zx::Event::create()?;
let id = id_handle.get_koid()?.raw_koid();
Ok(Self { id, id_handle })
}
pub fn get(&self) -> SessionId {
self.id
}
}