Tracking Issue: dart binding examples, tests, docs && publish
continue of
https://github.com/apache/opendal/pull/5591#issuecomment-2709719186
- [x] examples
- [x] tests
- [ ] docs
- [ ] publish
Hi, @asukaminato0721. It would be great if we could list all the tasks here directly.
The current usage is:
import 'opendal.dart';
void main() async {
await RustLib.init();
final File = FileManager.initOp(schemeStr: "fs", map: {"root": "/tmp"});
// drop-in
final file = File('file.txt');
var is_exists = await file.exists();
print(is_exists);
}
- Is this how the end users will use opendal after we publish it?
- Is
RustLib.init()required? What will happen if users have multiple rust lib? Can we hide it underFileManager::init? FileManager.initOpseems not a good API name.Opshouldn't have any meaning to dart users I guess. Can we useFileManager.initorFileManager.new?
The initialization might be related to some system resources, so we expect users to initialize it only once and use it everywhere instead of creating a new one each time. Can we share the same instance? For example, can we use the same manager for Directory?
The users will use import 'package:opendal/opendal.dart'; since this is the mainstream style.
Is RustLib.init() required?
yes
What will happen if users have multiple rust lib?
Warning but no error.
Can we hide it under
FileManager::init?
~~My consideration is that, if user want multiple op, this will be triggered many times,~~
I find out how to check the state now.
expect(RustLib.instance.initialized, false);
expect(() => RustLib.instance.api, throwsA(isA<StateError>()));
await RustLib.init();
expect(RustLib.instance.initialized, true);
may be useful.
The api name will be changed afterwards.
The initialization might be related to some system resources, so we expect users to initialize it only once and use it everywhere instead of creating a new one each time. Can we share the same instance? For example, can we use the same manager for
Directory?
Oh, just add another init method is enough.