<feed xmlns='http://www.w3.org/2005/Atom'>
<title>mirrors/arti.git/crates/tor-rpcbase/src/obj, branch arti-v1.1.9</title>
<subtitle>mirror of https://gitlab.torproject.org/tpo/core/arti
</subtitle>
<id>http://git.dilluti0n.com/mirrors/arti.git/atom?h=arti-v1.1.9</id>
<link rel='self' href='http://git.dilluti0n.com/mirrors/arti.git/atom?h=arti-v1.1.9'/>
<link rel='alternate' type='text/html' href='http://git.dilluti0n.com/mirrors/arti.git/'/>
<updated>2023-08-23T09:34:00Z</updated>
<entry>
<title>Run maint/add_warning to add lint block everywhere</title>
<updated>2023-08-23T09:34:00Z</updated>
<author>
<name>Ian Jackson</name>
<email>ijackson@chiark.greenend.org.uk</email>
</author>
<published>2023-08-22T14:28:12Z</published>
<link rel='alternate' type='text/html' href='http://git.dilluti0n.com/mirrors/arti.git/commit/?id=42df88d6bf6dbb460d2e5e1cd4838aafaffbe9ac'/>
<id>urn:sha1:42df88d6bf6dbb460d2e5e1cd4838aafaffbe9ac</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Fix typos</title>
<updated>2023-07-22T07:10:34Z</updated>
<author>
<name>Dimitris Apostolou</name>
<email>dimitris.apostolou@icloud.com</email>
</author>
<published>2023-07-22T07:10:34Z</published>
<link rel='alternate' type='text/html' href='http://git.dilluti0n.com/mirrors/arti.git/commit/?id=947ddfff0cfac3fef0e3d7ebc14182c638a1d90b'/>
<id>urn:sha1:947ddfff0cfac3fef0e3d7ebc14182c638a1d90b</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Run maint/add_warning to actually apply new lint allows</title>
<updated>2023-07-10T12:49:51Z</updated>
<author>
<name>Ian Jackson</name>
<email>ijackson@chiark.greenend.org.uk</email>
</author>
<published>2023-07-10T11:19:32Z</published>
<link rel='alternate' type='text/html' href='http://git.dilluti0n.com/mirrors/arti.git/commit/?id=473447a82e099fd52a674c28f5bc24b3e05208c0'/>
<id>urn:sha1:473447a82e099fd52a674c28f5bc24b3e05208c0</id>
<content type='text'>
</content>
</entry>
<entry>
<title>rpc: Remove some verbiage about 'static, and demo that it's OK without</title>
<updated>2023-06-15T11:07:11Z</updated>
<author>
<name>Ian Jackson</name>
<email>ijackson@chiark.greenend.org.uk</email>
</author>
<published>2023-06-15T10:29:26Z</published>
<link rel='alternate' type='text/html' href='http://git.dilluti0n.com/mirrors/arti.git/commit/?id=1710ce54f4d3c731328491718cc70f0d92639670'/>
<id>urn:sha1:1710ce54f4d3c731328491718cc70f0d92639670</id>
<content type='text'>
It's now not actually possible to write code that doesn't work, even
if `Tr` *isn't* 'static, because of the bounds on `CastTable::insert`.

I tried to produce a non-working setup with a non-static `Simple`, but
you can't implement `Object` for such a thing.  Removing 'static from
Object would stop the downcasts from Any to Object working.

Prior to the new typesafe insert, this change
  - let f: fn(&amp;dyn $crate::Object) -&gt; &amp;(dyn $traitname + 'static) = |self_| {
  + let f: fn(&amp;dyn $crate::Object) -&gt; &amp;(dyn $traitname) = |self_| {
would result in a runtime crash.  Now it results in a compiler error.
</content>
</entry>
<entry>
<title>rpc: Give the name `O` to "the type associated with this CastTable"</title>
<updated>2023-06-15T11:03:53Z</updated>
<author>
<name>Ian Jackson</name>
<email>ijackson@chiark.greenend.org.uk</email>
</author>
<published>2023-06-15T10:36:36Z</published>
<link rel='alternate' type='text/html' href='http://git.dilluti0n.com/mirrors/arti.git/commit/?id=0eedf0e2548587b77295ba8180fd926d8eee3ee1'/>
<id>urn:sha1:0eedf0e2548587b77295ba8180fd926d8eee3ee1</id>
<content type='text'>
This was locally bound to `S` in one place.  Bind and use it throughout.
Since this is an RPC object, `O` is a better name.

In each item, use the description once and thereafter just the name.
</content>
</entry>
<entry>
<title>rpc: Add Simple test case for CastTable</title>
<updated>2023-06-15T11:03:53Z</updated>
<author>
<name>Ian Jackson</name>
<email>ijackson@chiark.greenend.org.uk</email>
</author>
<published>2023-06-15T10:28:51Z</published>
<link rel='alternate' type='text/html' href='http://git.dilluti0n.com/mirrors/arti.git/commit/?id=2228751a007aeab35f40c97174520e0268469e5d'/>
<id>urn:sha1:2228751a007aeab35f40c97174520e0268469e5d</id>
<content type='text'>
</content>
</entry>
<entry>
<title>rpc: Move boxing from macro to CastTable::insert (formatting)</title>
<updated>2023-06-15T11:03:53Z</updated>
<author>
<name>Ian Jackson</name>
<email>ijackson@chiark.greenend.org.uk</email>
</author>
<published>2023-06-15T11:03:43Z</published>
<link rel='alternate' type='text/html' href='http://git.dilluti0n.com/mirrors/arti.git/commit/?id=54b364cdcf324200c0dbfdc0012f7397510874ec'/>
<id>urn:sha1:54b364cdcf324200c0dbfdc0012f7397510874ec</id>
<content type='text'>
</content>
</entry>
<entry>
<title>rpc: Move boxing from macro to CastTable::insert</title>
<updated>2023-06-15T10:32:32Z</updated>
<author>
<name>Ian Jackson</name>
<email>ijackson@chiark.greenend.org.uk</email>
</author>
<published>2023-06-15T10:23:03Z</published>
<link rel='alternate' type='text/html' href='http://git.dilluti0n.com/mirrors/arti.git/commit/?id=890a7b52be529b3ae810581a2ad4b26dccdb7320'/>
<id>urn:sha1:890a7b52be529b3ae810581a2ad4b26dccdb7320</id>
<content type='text'>
</content>
</entry>
<entry>
<title>rpc: Make CastTable::insert be more type-safe</title>
<updated>2023-06-15T10:13:26Z</updated>
<author>
<name>Ian Jackson</name>
<email>ijackson@chiark.greenend.org.uk</email>
</author>
<published>2023-06-15T10:11:09Z</published>
<link rel='alternate' type='text/html' href='http://git.dilluti0n.com/mirrors/arti.git/commit/?id=8452fe11cf8a18e788a35853ac378eef461b6af9'/>
<id>urn:sha1:8452fe11cf8a18e788a35853ac378eef461b6af9</id>
<content type='text'>
This checks the Requirements.
</content>
</entry>
<entry>
<title>RPC: Functionality to downcast dyn Object to a dyn Trait.</title>
<updated>2023-06-12T17:35:28Z</updated>
<author>
<name>Nick Mathewson</name>
<email>nickm@torproject.org</email>
</author>
<published>2023-06-07T17:30:36Z</published>
<link rel='alternate' type='text/html' href='http://git.dilluti0n.com/mirrors/arti.git/commit/?id=8166a29746b8fa7b447fc0f3929668e35c3314ae'/>
<id>urn:sha1:8166a29746b8fa7b447fc0f3929668e35c3314ae</id>
<content type='text'>
This is a rather tricky piece of functionality.  It works as
follows.

We introduce a `CastTable` type.  Each `CastTable` tells us how to
downcast `dyn Object` for objects of a single concrete type.
The `Object` type now has a `get_casttable` method that returns
an empty `CastTable` by default.

`CastTable` is, internally, a map from the `TypeId` of the target
dyn Trait reference type to a function
`fn(&amp;dyn Object) -&gt; &amp;dyn Trait`.  These functions are stored as
`Box&lt;dyn Any + ...&gt;`.  (They are Boxed because they may refer to
generic functions, which you can't get a static reference to,
and they're Any because the functions have different types.)

The `decl_object!` macro now implements `get_casttable` as
appropriate.  (The syntax is a bit janky, but that's what we get
for not using derive_adhoc.)  For non-generic types, `get_casttable`
uses a Lazy&lt;CastTable&gt;`. to initialize a CastTable exactly once.
For generic types, it use a `Lazy&lt;RwLock&lt;HashMap&lt;..&gt;&gt;` to
build one CastTable per instantiation of the generic type.

This could probably be optimized a bit more, the yaks could be
shaved in a more scintillating hairstyle, and the syntax for
generic `decl_object` could definitely be improved.
</content>
</entry>
</feed>
