forked from RustPython/RustPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmod.rs
More file actions
41 lines (37 loc) · 1.25 KB
/
mod.rs
File metadata and controls
41 lines (37 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
mod argument;
mod arithmetic;
mod buffer;
mod builtin;
mod either;
mod number;
mod protocol;
pub use argument::{
ArgumentError, FromArgOptional, FromArgs, FuncArgs, IntoFuncArgs, KwArgs, OptionalArg,
OptionalOption, PosArgs,
};
pub use arithmetic::{PyArithmeticValue, PyComparisonValue};
pub use buffer::{ArgAsciiBuffer, ArgBytesLike, ArgMemoryBuffer, ArgStrOrBytesLike};
pub use builtin::{IntoPyNativeFunc, OwnedParam, PyNativeFunc, RefParam};
pub use either::Either;
pub use number::{ArgIntoBool, ArgIntoComplex, ArgIntoFloat};
pub use protocol::{ArgCallable, ArgIterable, ArgMapping, ArgSequence};
use crate::{builtins::PyStr, convert::TryFromBorrowedObject, PyObject, PyResult, VirtualMachine};
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum ArgByteOrder {
Big,
Little,
}
impl TryFromBorrowedObject for ArgByteOrder {
fn try_from_borrowed_object(vm: &VirtualMachine, obj: &PyObject) -> PyResult<Self> {
obj.try_value_with(
|s: &PyStr| match s.as_str() {
"big" => Ok(Self::Big),
"little" => Ok(Self::Little),
_ => {
Err(vm.new_value_error("byteorder must be either 'little' or 'big'".to_owned()))
}
},
vm,
)
}
}