pub struct StdlibMappings { /* private fields */ }Expand description
Stdlib API mapping registry
Implementations§
Source§impl StdlibMappings
impl StdlibMappings
Sourcepub fn lookup(
&self,
module: &str,
class: &str,
attribute: &str,
) -> Option<&RustPattern>
pub fn lookup( &self, module: &str, class: &str, attribute: &str, ) -> Option<&RustPattern>
Look up mapping for a Python API call
Sourcepub fn has_iteration_mapping(&self, module: &str, class: &str) -> bool
pub fn has_iteration_mapping(&self, module: &str, class: &str) -> bool
Check if a class has iteration mapping
Sourcepub fn get_iteration_pattern(
&self,
module: &str,
class: &str,
) -> Option<&RustPattern>
pub fn get_iteration_pattern( &self, module: &str, class: &str, ) -> Option<&RustPattern>
Get iteration pattern for a class
Sourcepub fn register(&mut self, mapping: StdlibApiMapping)
pub fn register(&mut self, mapping: StdlibApiMapping)
Register a custom mapping (public API for plugins)
§Example
use depyler_core::stdlib_mappings::{StdlibMappings, StdlibApiMapping, RustPattern};
let mut mappings = StdlibMappings::new();
mappings.register(StdlibApiMapping {
module: "requests",
class: "Session",
python_attr: "get",
rust_pattern: RustPattern::MethodCall {
method: "get",
extra_args: vec![],
propagate_error: true,
},
});Sourcepub fn register_batch(&mut self, mappings: Vec<StdlibApiMapping>)
pub fn register_batch(&mut self, mappings: Vec<StdlibApiMapping>)
Register multiple mappings at once
Sourcepub fn load_plugin(&mut self, plugin: &dyn StdlibPlugin)
pub fn load_plugin(&mut self, plugin: &dyn StdlibPlugin)
Load a plugin into the registry
§Example
use depyler_core::stdlib_mappings::{StdlibMappings, StdlibPlugin};
struct MyPlugin;
impl StdlibPlugin for MyPlugin {
fn register_mappings(&self, registry: &mut StdlibMappings) {
// Register custom mappings
}
fn name(&self) -> &str { "my_plugin" }
}
let mut mappings = StdlibMappings::new();
mappings.load_plugin(&MyPlugin);Sourcepub fn load_plugins(&mut self, plugins: &[&dyn StdlibPlugin])
pub fn load_plugins(&mut self, plugins: &[&dyn StdlibPlugin])
Load multiple plugins at once
Trait Implementations§
Auto Trait Implementations§
impl Freeze for StdlibMappings
impl RefUnwindSafe for StdlibMappings
impl Send for StdlibMappings
impl Sync for StdlibMappings
impl Unpin for StdlibMappings
impl UnwindSafe for StdlibMappings
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more