Fix formatting/syntax issues with docs
This commit is contained in:
@@ -154,14 +154,13 @@ Also, one weird case is for Void types in Unions (and in general, but Void is re
|
||||
|
||||
bob.employment.unemployed = None
|
||||
|
||||
.. note:: One caveat for unions is having structs as union members. Let us assume `employment.school` was actually a struct with a field of type `Text` called `name`::
|
||||
.. note:: One caveat for unions is having structs as union members. Let us assume `employment.school` was actually a struct with a field of type `Text` called `name`
|
||||
|
||||
alice.employment.school.name = "MIT"
|
||||
# Raises a KjException
|
||||
|
||||
The problem is that a struct within a union isn't initialized automatically. You have to do the following::
|
||||
|
||||
TODO Broken
|
||||
school = alice.employment.init('school')
|
||||
school.name = "MIT"
|
||||
|
||||
@@ -180,14 +179,13 @@ There is also a `write_packed` function, that writes out the message more space-
|
||||
Writing to a socket
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
Alternatively, you can write to a socket. This is useful if you want to send the message over the network or to another process.
|
||||
A full example of this is available on GitHub `examples/async_socket_message_client.py <https://github.com/capnproto/pycapnp/blob/master/examples/async_socket_message_client.py>`_.
|
||||
|
||||
.. important:: Writing to a socket is implemented using asyncio and requires a running event loop both for the python part (asyncio) and the C++ part (KJ). See :ref:`RPC <kj-event-loop>` for more information.
|
||||
::
|
||||
A full example of this is available on GitHub `examples/async_socket_message_client.py <https://github.com/capnproto/pycapnp/blob/master/examples/async_socket_message_client.py>`_.::
|
||||
|
||||
stream = await capnp.AsyncIoStream.create_connection(host="localhost", port=6000)
|
||||
await addresses.write_async(stream)
|
||||
|
||||
.. important:: Writing to a socket is implemented using asyncio and requires a running event loop both for the python part (asyncio) and the C++ part (KJ). See :ref:`RPC <kj-event-loop>` for more information.
|
||||
|
||||
Read a message
|
||||
--------------
|
||||
|
||||
@@ -211,14 +209,13 @@ Reading from a socket
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The same as for writing, you can read from a socket. This is useful if you want to receive the message over the network or from another process.
|
||||
A full example of this is available on GitHub `examples/async_socket_message_client.py <https://github.com/capnproto/pycapnp/blob/master/examples/async_socket_message_client.py>`_.
|
||||
|
||||
.. important:: Reading from a socket is implemented using asyncio and requires a running event loop both for the python part (asyncio) and the C++ part (KJ). See :ref:`RPC <kj-event-loop>` for more information.
|
||||
::
|
||||
A full example of this is available on GitHub `examples/async_socket_message_client.py <https://github.com/capnproto/pycapnp/blob/master/examples/async_socket_message_client.py>`_.::
|
||||
|
||||
stream = await capnp.AsyncIoStream.create_connection(host="localhost", port=6000)
|
||||
message = await addressbook_capnp.AddressBook.read_async(stream)
|
||||
|
||||
.. important:: Reading from a socket is implemented using asyncio and requires a running event loop both for the python part (asyncio) and the C++ part (KJ). See :ref:`RPC <kj-event-loop>` for more information.
|
||||
|
||||
|
||||
Reading Fields
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
Reference in New Issue
Block a user