quickjs_rusty/value/
atom.rs

1use libquickjs_ng_sys as q;
2
3pub struct OwnedJsAtom {
4    context: *mut q::JSContext,
5    value: q::JSAtom,
6}
7
8impl OwnedJsAtom {
9    #[inline]
10    pub fn new(context: *mut q::JSContext, value: q::JSAtom) -> Self {
11        Self { context, value }
12    }
13}
14
15impl Drop for OwnedJsAtom {
16    fn drop(&mut self) {
17        unsafe {
18            q::JS_FreeAtom(self.context, self.value);
19        }
20    }
21}
22
23impl Clone for OwnedJsAtom {
24    fn clone(&self) -> Self {
25        unsafe { q::JS_DupAtom(self.context, self.value) };
26        Self {
27            context: self.context,
28            value: self.value,
29        }
30    }
31}