rust-vmm / vm-memory

Virtual machine's guest memory crate
Apache License 2.0
306 stars 98 forks source link

Add new method as_any() to GuestAddressSpace #192

Open jiangliu opened 2 years ago

jiangliu commented 2 years ago

Add new method as_any() to GuestAddressSpace, which returns reference to a std::any::Any trait object. Then downcast_ref() could be used to get the concrete type of GuestAddressSpace trait object.

Signed-off-by: Liu Jiang gerry@linux.alibaba.com

Summary of the PR

Please summarize here why the changes in this PR are needed.

Requirements

Before submitting your PR, please make sure you addressed the following requirements:

lauralt commented 2 years ago

@jiangliu can you fix the conflicts so we can merge the PR? Thanks.

jiangliu commented 2 years ago

@jiangliu can you fix the conflicts so we can merge the PR? Thanks.

@lauralt hi, I have updated the PR, thanks:)

bonzini commented 2 years ago

Sorry, I think the extra 'static bound is a problem, especially when the GuestAddressSpace is just &M. I don't think this pull request can be salvaged, you should just use external crates like as_any or downcast.

bonzini commented 2 years ago

(Did not mean to close, sorry).