Skip to content

spencerwilson/dep-injection-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dependency injection from Python into Rust

A demo of calling a Python callback from Rust.

End goal is a Rust-backed Python module sdk that creates SDK clients which can be configured at construction-time with custom implementations of internal components (e.g., logging, HTTP requesting, etc.) defined in Python.

The following is an example with a Logger interface.

import sdk

class Logger(object):
    def log(msg):
        print('got:', msg)

client = sdk.Client(logger=Logger)  # Instantiate an SDK client

result = client.add(1, 2)           # Should log 'got: computed 1 + 2 = 3'
assert result == 3

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published