Skip to content

Commit

Permalink
Implement most of the rest of the accessors
Browse files Browse the repository at this point in the history
Now I want to refactor it all again.
  • Loading branch information
ObsidianMinor committed Oct 14, 2024
1 parent 06f004f commit 800104a
Show file tree
Hide file tree
Showing 3 changed files with 787 additions and 197 deletions.
19 changes: 0 additions & 19 deletions doc/todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,6 @@
* We need to test the different patterns that are expected to be usable by users of the library.

- [ ] Field accessors! Because someone 5 years ago thought it'd be a good idea to implement them in the library.
- [ ] `PtrVariantOwner` generic accessors
* Needs `by_ref`, `init_field`, `field`, `is_null`, `adopt`, `disown_into`, `try_clear`, and `clear` methods. We can basically just copy `PtrVariantBuilder` for this.
- [ ] `PtrFieldBuilder` for `List<AnyStruct>`
* Needs `try_set`, `set`, and `try_init`
- [ ] `PtrFieldOwner` for `List<V>`
* Copy from `PtrFieldBuilder`. Change lifetimes as appropriate.
- [ ] `PtrVariantBuilder` for `List<V>`
* Needs `get`, `try_set`, `set`, `init`, `try_init`, `init_with_size`. Essentially just the same accessors as `PtrFieldBuilder` but based on the variant helpers.
* We also need the accessors from `List<AnyStruct>` which is slightly different due to the lack of fixed size to check.
- [ ] `PtrVariantOwner` for `List<V>`
* Copy from `PtrVariantBuilder`.
- [ ] `PtrFieldOwner` and `PtrVariantOwner` for `Struct<S>`
- [ ] `PtrVariantReader` and`PtrVariantBuilder` for `Text`
- [ ] `PtrVariantReader` and `PtrVariantBuilder` for `Data`
- [ ] `PtrVariantReader`, `PtrVariantBuilder`, and `PtrVariantOwner` for `AnyPtr`
* Probably just needs an alias or two for the obvious ops.
- [ ] `PtrFieldBuilder`, `PtrFieldOwner`, `PtrVariantReader`, `PtrVariantBuilder`, and `PtrVariantOwner` for `AnyStruct`
- [ ] `PtrFieldBuilder`, `PtrFieldOwner`, `PtrVariantReader`, `PtrVariantBuilder`, and `PtrVariantOwner` for `AnyList`
- [ ] `PtrFieldReader`, `PtrFieldBuilder`, `PtrVariantReader`, and `PtrVariantBuilder` for `Capability<C>`
- [ ] Support "any" capability. We need some sort of marker for the type. Other than that it just returns whatever the `CapSystem`'s `Cap` type is.
- [ ] List accessors! Same thing as field accessors, but for list elements!
- As a whole, list accessors need to be refactored to be more inline with field accessors in their current state. This brings with it better reusability of ptr element accessors like `is_null`, `clear`, `adopt`, and `disown_into`.
Expand Down
6 changes: 1 addition & 5 deletions examples/addressbook/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,13 @@ pub fn write_address_book<W: Write>(target: &mut W) {
alice.id().set(123);
alice.name().set(text!("Alice"));
alice.email().set(text!("alice@example.com"));
alice.employment().school().set_str("MIT");

let mut alice_phones = alice.phones().init(1);
let mut phone = alice_phones.at(0).get();
phone.number().set(text!("555-1212"));
phone.r#type().set(person::phone_number::Type::Mobile);

let mut employment = alice.employment();
let school = employment.school();
let field = school.init_field();
field.set_str("MIT");

let mut bob = people.at(1).get();
bob.id().set(456);
bob.name().set(text!("Bob"));
Expand Down
Loading

0 comments on commit 800104a

Please sign in to comment.