MCPcopy Index your code
hub / github.com/RustPython/RustPython / parse_path_arg

Method parse_path_arg

crates/stdlib/src/ssl.rs:1992–2001  ·  view source on GitHub ↗

Parse path argument (str or bytes) to string

(
            arg: &Either<PyStrRef, ArgBytesLike>,
            vm: &VirtualMachine,
        )

Source from the content-addressed store, hash-verified

1990
1991 /// Parse path argument (str or bytes) to string
1992 fn parse_path_arg(
1993 arg: &Either<PyStrRef, ArgBytesLike>,
1994 vm: &VirtualMachine,
1995 ) -> PyResult<String> {
1996 match arg {
1997 Either::A(s) => Ok(s.clone().try_into_utf8(vm)?.as_str().to_owned()),
1998 Either::B(b) => String::from_utf8(b.borrow_buf().to_vec())
1999 .map_err(|_| vm.new_value_error("path contains invalid UTF-8")),
2000 }
2001 }
2002
2003 /// Parse password argument (str, bytes-like, or callable)
2004 ///

Callers

nothing calls this directly

Calls 6

try_into_utf8Method · 0.80
to_vecMethod · 0.80
to_ownedMethod · 0.45
as_strMethod · 0.45
cloneMethod · 0.45
borrow_bufMethod · 0.45

Tested by

no test coverage detected