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

Function encode_string

crates/vm/src/builtins/str.rs:1657–1668  ·  view source on GitHub ↗
(
    s: PyStrRef,
    encoding: Option<PyUtf8StrRef>,
    errors: Option<PyUtf8StrRef>,
    vm: &VirtualMachine,
)

Source from the content-addressed store, hash-verified

1655}
1656
1657pub(crate) fn encode_string(
1658 s: PyStrRef,
1659 encoding: Option<PyUtf8StrRef>,
1660 errors: Option<PyUtf8StrRef>,
1661 vm: &VirtualMachine,
1662) -> PyResult<PyBytesRef> {
1663 let encoding = match encoding.as_ref() {
1664 None => crate::codecs::DEFAULT_ENCODING,
1665 Some(s) => s.as_str(),
1666 };
1667 vm.state.codec_registry.encode_text(s, encoding, errors, vm)
1668}
1669
1670impl PyPayload for PyStr {
1671 #[inline]

Callers 2

encodeMethod · 0.70
get_value_from_stringMethod · 0.50

Calls 3

encode_textMethod · 0.80
as_refMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected