Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 307fac7

Browse files
committed
Draft methods for Token object
1 parent 6676809 commit 307fac7

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

stdlib/src/contextvars.rs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,41 @@ mod _contextvars {
150150
#[derive(Debug, PyValue)]
151151
struct ContextToken {}
152152

153+
#[derive(FromArgs)]
154+
struct ContextTokenOptions {
155+
#[pyarg(positional)]
156+
#[allow(dead_code)] // TODO: RUSTPYTHON
157+
context: PyObjectRef,
158+
#[pyarg(positional)]
159+
#[allow(dead_code)] // TODO: RUSTPYTHON
160+
var: PyObjectRef,
161+
#[pyarg(positional)]
162+
#[allow(dead_code)] // TODO: RUSTPYTHON
163+
old_value: PyObjectRef,
164+
}
165+
153166
#[pyimpl]
154-
impl ContextToken {}
167+
impl ContextToken {
168+
#[pymethod(magic)]
169+
fn init(&self, _args: ContextTokenOptions, _vm: &VirtualMachine) -> PyResult<()> {
170+
unimplemented!("Token.__init__() is currently under construction")
171+
}
172+
173+
#[pyproperty]
174+
fn var(&self, _vm: &VirtualMachine) -> PyObjectRef {
175+
unimplemented!("Token.var() is currently under construction")
176+
}
177+
178+
#[pyproperty]
179+
fn old_value(&self, _vm: &VirtualMachine) -> PyObjectRef {
180+
unimplemented!("Token.old_value() is currently under construction")
181+
}
182+
183+
#[pymethod(magic)]
184+
fn repr(_zelf: PyRef<Self>, _vm: &VirtualMachine) -> String {
185+
unimplemented!("<Token {{}}var={{}} at {{}}>")
186+
}
187+
}
155188

156189
#[pyfunction]
157190
fn copy_context() {}

0 commit comments

Comments
 (0)