rustpython_vm/function/
mod.rs1mod argument;
2mod arithmetic;
3mod buffer;
4mod builtin;
5mod either;
6mod fspath;
7mod getset;
8mod method;
9mod number;
10mod protocol;
11mod time;
12
13pub use argument::{
14 ArgumentError, FromArgOptional, FromArgs, FuncArgs, IntoFuncArgs, KwArgs, OptionalArg,
15 OptionalOption, PosArgs,
16};
17pub use arithmetic::{PyArithmeticValue, PyComparisonValue};
18pub use buffer::{ArgAsciiBuffer, ArgBytesLike, ArgMemoryBuffer, ArgStrOrBytesLike};
19pub use builtin::{IntoPyNativeFn, PyNativeFn, static_func, static_raw_func};
20pub use either::Either;
21pub use fspath::FsPath;
22pub use getset::PySetterValue;
23pub(super) use getset::{IntoPyGetterFunc, IntoPySetterFunc, PyGetterFunc, PySetterFunc};
24pub use method::{HeapMethodDef, PyMethodDef, PyMethodFlags};
25pub use number::{ArgIndex, ArgIntoBool, ArgIntoComplex, ArgIntoFloat, ArgPrimitiveIndex, ArgSize};
26pub use protocol::{ArgCallable, ArgIterable, ArgMapping, ArgSequence};
27pub use time::TimeoutSeconds;
28
29use crate::{PyObject, PyResult, VirtualMachine, builtins::PyStr, convert::TryFromBorrowedObject};
30use builtin::{BorrowedParam, OwnedParam, RefParam};
31
32#[derive(Clone, Copy, PartialEq, Eq)]
33pub enum ArgByteOrder {
34 Big,
35 Little,
36}
37
38impl<'a> TryFromBorrowedObject<'a> for ArgByteOrder {
39 fn try_from_borrowed_object(vm: &VirtualMachine, obj: &'a PyObject) -> PyResult<Self> {
40 obj.try_value_with(
41 |s: &PyStr| match s.as_bytes() {
42 b"big" => Ok(Self::Big),
43 b"little" => Ok(Self::Little),
44 _ => Err(vm.new_value_error("byteorder must be either 'little' or 'big'")),
45 },
46 vm,
47 )
48 }
49}