Comments (8)
Also, with the current approach, I can't call self.store.commit
in a Resource method (e.g. resource.save()
):
the `commit` method cannot be invoked on a trait objectrustc
storelike.rs(76, 15): this has a `Sized` requirement
from atomic-server.
I've posted this question to StackOverlfow. https://stackoverflow.com/questions/64975080/invoking-a-method-on-a-trait-object
from atomic-server.
This issue is just the worst... It keeps coming back in all kinds of situations - the sized
constraints on the many Storelike
methods severely limit where I can call them.
I see no other option than to drastically change the Resource
API, and remove the reference to Storelike
from Resource
. This means that most of the Resource
methods will now explicitly require.
from atomic-server.
I've tried changing the Resource
API, remove the Store
reference, but that didn't fix all instances of this issue. The issue happens whenever I call a method that uses Storelike
as an argument.
For example, when creating a new Collection::new
, Storelike.tpf()
is called. This means that Collection::new
needs to be compiled for different sizes of Storelike
structs. And for this to work, Storelike
needs to be sized
.
With the refactor I suggested above, I explicitly pass Store
to many Resource
methods. The result, unfortunately, is that now all the Storelike methods that call Resource methods that use Storelike (self) need to be sized.... E.g. resource.get_shortname(&item, self)
is called in Storelike.get_path
, which means that now get_path
needs a where self is Sized
thing.
from atomic-server.
Just tried adding :Sized
to the trait, and replacing all dyn Storelike
with impl Storelike
... And so far, it seems to work!
from atomic-server.
However, when I try to do this while keeping a reference to Storelike
in Resource
, things fall apart again:
pub struct Resource<'a> {
propvals: PropVals,
subject: String,
classes: Option<Vec<Class>>,
// `impl Trait` not allowed outside of function and inherent method return types rustcE0562
store: &'a impl Storelike,
commit: CommitBuilder,
}
One possible solution to this, was to use Generics. Just tried that, but I also fail to get that working.
from atomic-server.
I kind of fixed it, but it still doesn't feel right. I set a :Sized
bound for the entire Storelike
trait, which also means that I can't keep a reference to it in other structs, such as Resource
. This caused me to refactor quite a bit, and the API got a little worse because of it. Adjusting a resource (e.g. setting a property) now requires explicitly passing the store. Some might prefer it, though, and it does enable multi-store workflows / passing resources from store to store.
Anyway - I can now do all the things i needed to do. Use impl Storelike
instead of dyn Storelike
if you want to stay out of trouble. Closing.
from atomic-server.
Well, it turns out setting :Sized also comes with some serious limitations. I'm working on a plugin #73 system, which includes structs that contain functions that refer to Storelike
. And that's a problem, because Storelike
is sized, and that means I can't use &impl Storelike
in that function.
I think there are two solutions to this:
- Get rid of one of the implementations (which will be the in-memory one)
- Move all the error-causing logic from the trait. Might involve some code duplication, but I get to keep both implementations.
from atomic-server.
Related Issues (20)
- When class was not selected properly the first time later it does not allow to select it.
- Resource record disappears when ascending is applied.
- Mouse pointer is jumping while editing class name, it should keep the position if possible
- For long properties layout breaks and such names must be truncated
- Properties in the data atoms window ares not properly aligned.
- The sequence of properties in card view does not match the one in the table view.
- Introduce the financial format for Number Column
- Pop-up with a full column name when the name is truncated
- The standard report for class-used-in is missing from the class overview (available in the data view only)
- When creating a new column, the description edit is not available.
- The "delete drive" button should be available.
- Description of a drive is not available HOT 1
- In search results query the type of the found items are not shown, making it difficult to navigate
- Bugs during copy-paste of the values
- Lookup works only with the default "Name" column
- Lookup window opens up and closes the class name, so the user needs to remember it instead of just looking. HOT 2
- Deleted classes are still in the lookup drop-down, introducing confusion. HOT 4
- Potential GPL License violation HOT 3
- Multiple resource parents are displayed
- In Atoms percentage values are shown without % sign
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from atomic-server.