rustorb 0.2.0__tar.gz → 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. {rustorb-0.2.0 → rustorb-0.3.0}/Cargo.lock +17 -17
  2. {rustorb-0.2.0 → rustorb-0.3.0}/Cargo.toml +6 -6
  3. {rustorb-0.2.0 → rustorb-0.3.0}/PKG-INFO +1 -1
  4. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-cdr/src/encoder.rs +58 -4
  5. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-cdr/src/value.rs +2 -0
  6. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-cdr/src/xcdr.rs +1 -1
  7. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/src/connection.rs +260 -29
  8. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/src/lib.rs +3 -3
  9. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/src/object.rs +8 -0
  10. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/src/orb.rs +76 -13
  11. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/src/pi.rs +1 -0
  12. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/src/poa.rs +18 -0
  13. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/src/policy.rs +73 -16
  14. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/src/server.rs +302 -29
  15. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/src/typecode/cdr.rs +4 -0
  16. rustorb-0.3.0/crates/rustorb-core/tests/bidir.rs +487 -0
  17. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/tests/pi.rs +60 -22
  18. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/tests/trace.rs +1 -1
  19. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-giop/src/lib.rs +3 -1
  20. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-giop/src/service_context.rs +113 -0
  21. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-giop/src/writer.rs +78 -4
  22. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-giop/tests/giop.rs +111 -0
  23. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-python/src/poa.rs +7 -5
  24. {rustorb-0.2.0 → rustorb-0.3.0}/pyproject.toml +1 -1
  25. rustorb-0.3.0/rustorb/BiDirPolicy.py +38 -0
  26. {rustorb-0.2.0 → rustorb-0.3.0}/rustorb/CORBA.py +4 -0
  27. {rustorb-0.2.0 → rustorb-0.3.0}/README.md +0 -0
  28. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-cdr/Cargo.toml +0 -0
  29. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-cdr/LICENSE-APACHE +0 -0
  30. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-cdr/LICENSE-MIT +0 -0
  31. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-cdr/README.md +0 -0
  32. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-cdr/src/decoder.rs +0 -0
  33. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-cdr/src/error.rs +0 -0
  34. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-cdr/src/lib.rs +0 -0
  35. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-cdr/src/long_double.rs +0 -0
  36. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-cdr/src/octets.rs +0 -0
  37. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-cdr/src/traits.rs +0 -0
  38. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-cdr/tests/cdr.rs +0 -0
  39. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-cdr/tests/xcdr.rs +0 -0
  40. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/Cargo.toml +0 -0
  41. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/LICENSE-APACHE +0 -0
  42. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/LICENSE-MIT +0 -0
  43. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/README.md +0 -0
  44. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/benches/throughput.rs +0 -0
  45. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/src/codeset.rs +0 -0
  46. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/src/dii.rs +0 -0
  47. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/src/dynany/mod.rs +0 -0
  48. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/src/dynany/tests.rs +0 -0
  49. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/src/exception.rs +0 -0
  50. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/src/fixed.rs +0 -0
  51. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/src/idl/abstract_iface.rs +0 -0
  52. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/src/idl/mod.rs +0 -0
  53. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/src/idl/tests.rs +0 -0
  54. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/src/idl/value.rs +0 -0
  55. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/src/idle.rs +0 -0
  56. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/src/iop.rs +0 -0
  57. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/src/name.rs +0 -0
  58. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/src/pool.rs +0 -0
  59. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/src/servant.rs +0 -0
  60. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/src/stream.rs +0 -0
  61. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/src/timeout.rs +0 -0
  62. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/src/tls.rs +0 -0
  63. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/src/trace.rs +0 -0
  64. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/src/typecode/mod.rs +0 -0
  65. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/src/typecode/tests.rs +0 -0
  66. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/src/value.rs +0 -0
  67. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/src/wire.rs +0 -0
  68. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/tests/any.rs +0 -0
  69. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/tests/async_api.rs +0 -0
  70. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/tests/client.rs +0 -0
  71. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/tests/connections.rs +0 -0
  72. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/tests/dii.rs +0 -0
  73. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/tests/message_size.rs +0 -0
  74. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/tests/poa.rs +0 -0
  75. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/tests/policy.rs +0 -0
  76. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/tests/server.rs +0 -0
  77. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/tests/soak.rs +0 -0
  78. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/tests/stress.rs +0 -0
  79. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/tests/tls/ca.pem +0 -0
  80. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/tests/tls/client-bundle.pem +0 -0
  81. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/tests/tls/client.key +0 -0
  82. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/tests/tls/client.pem +0 -0
  83. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/tests/tls/make-certs.sh +0 -0
  84. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/tests/tls/other-ca.pem +0 -0
  85. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/tests/tls/other-server.key +0 -0
  86. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/tests/tls/other-server.pem +0 -0
  87. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/tests/tls/server-bundle.pem +0 -0
  88. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/tests/tls/server.key +0 -0
  89. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/tests/tls/server.pem +0 -0
  90. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/tests/tls/wrong-name.key +0 -0
  91. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/tests/tls/wrong-name.pem +0 -0
  92. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/tests/tls.rs +0 -0
  93. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-core/tests/valuetype.rs +0 -0
  94. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-giop/Cargo.toml +0 -0
  95. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-giop/LICENSE-APACHE +0 -0
  96. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-giop/LICENSE-MIT +0 -0
  97. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-giop/README.md +0 -0
  98. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-giop/src/component.rs +0 -0
  99. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-giop/src/corbaloc.rs +0 -0
  100. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-giop/src/error.rs +0 -0
  101. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-giop/src/fragment.rs +0 -0
  102. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-giop/src/header.rs +0 -0
  103. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-giop/src/iiop.rs +0 -0
  104. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-giop/src/ior.rs +0 -0
  105. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-giop/src/message.rs +0 -0
  106. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-giop/tests/ior.rs +0 -0
  107. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-giop/tests/omniorb_golden.rs +0 -0
  108. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-python/Cargo.toml +0 -0
  109. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-python/LICENSE-APACHE +0 -0
  110. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-python/LICENSE-MIT +0 -0
  111. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-python/README.md +0 -0
  112. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-python/build.rs +0 -0
  113. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-python/src/any.rs +0 -0
  114. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-python/src/dii.rs +0 -0
  115. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-python/src/dynany.rs +0 -0
  116. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-python/src/error.rs +0 -0
  117. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-python/src/lib.rs +0 -0
  118. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-python/src/log.rs +0 -0
  119. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-python/src/orb.rs +0 -0
  120. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-python/src/pi.rs +0 -0
  121. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-python/src/tc.rs +0 -0
  122. {rustorb-0.2.0 → rustorb-0.3.0}/crates/rustorb-python/src/value.rs +0 -0
  123. {rustorb-0.2.0 → rustorb-0.3.0}/rustorb/DynamicAny.py +0 -0
  124. {rustorb-0.2.0 → rustorb-0.3.0}/rustorb/IOP.py +0 -0
  125. {rustorb-0.2.0 → rustorb-0.3.0}/rustorb/Messaging.py +0 -0
  126. {rustorb-0.2.0 → rustorb-0.3.0}/rustorb/PortableInterceptor.py +0 -0
  127. {rustorb-0.2.0 → rustorb-0.3.0}/rustorb/PortableServer.py +0 -0
  128. {rustorb-0.2.0 → rustorb-0.3.0}/rustorb/PortableServer__POA.py +0 -0
  129. {rustorb-0.2.0 → rustorb-0.3.0}/rustorb/TimeBase.py +0 -0
  130. {rustorb-0.2.0 → rustorb-0.3.0}/rustorb/__init__.py +0 -0
  131. {rustorb-0.2.0 → rustorb-0.3.0}/rustorb/_log.py +0 -0
  132. {rustorb-0.2.0 → rustorb-0.3.0}/rustorb/_native.pyi +0 -0
  133. {rustorb-0.2.0 → rustorb-0.3.0}/rustorb/_rt.py +0 -0
  134. {rustorb-0.2.0 → rustorb-0.3.0}/rustorb/_types.py +0 -0
  135. {rustorb-0.2.0 → rustorb-0.3.0}/rustorb/timeouts.py +0 -0
@@ -438,20 +438,11 @@ dependencies = [
438
438
 
439
439
  [[package]]
440
440
  name = "rustorb-cdr"
441
- version = "0.2.0"
442
-
443
- [[package]]
444
- name = "rustorb-codegen"
445
- version = "0.2.0"
446
- dependencies = [
447
- "rustorb-core",
448
- "rustorb-typesupport",
449
- "tokio",
450
- ]
441
+ version = "0.3.0"
451
442
 
452
443
  [[package]]
453
444
  name = "rustorb-core"
454
- version = "0.2.0"
445
+ version = "0.3.0"
455
446
  dependencies = [
456
447
  "criterion",
457
448
  "libc",
@@ -466,7 +457,7 @@ dependencies = [
466
457
 
467
458
  [[package]]
468
459
  name = "rustorb-ffi"
469
- version = "0.2.0"
460
+ version = "0.3.0"
470
461
  dependencies = [
471
462
  "rustorb-cdr",
472
463
  "rustorb-core",
@@ -474,7 +465,7 @@ dependencies = [
474
465
 
475
466
  [[package]]
476
467
  name = "rustorb-giop"
477
- version = "0.2.0"
468
+ version = "0.3.0"
478
469
  dependencies = [
479
470
  "rustorb-cdr",
480
471
  "serde_json",
@@ -482,22 +473,31 @@ dependencies = [
482
473
 
483
474
  [[package]]
484
475
  name = "rustorb-interop"
485
- version = "0.2.0"
476
+ version = "0.3.0"
486
477
  dependencies = [
487
478
  "rustorb-core",
488
479
  "rustorb-naming",
489
480
  ]
490
481
 
482
+ [[package]]
483
+ name = "rustorb-mapping-tests"
484
+ version = "0.0.0"
485
+ dependencies = [
486
+ "rustorb-core",
487
+ "rustorb-typesupport",
488
+ "tokio",
489
+ ]
490
+
491
491
  [[package]]
492
492
  name = "rustorb-naming"
493
- version = "0.2.0"
493
+ version = "0.3.0"
494
494
  dependencies = [
495
495
  "rustorb-core",
496
496
  ]
497
497
 
498
498
  [[package]]
499
499
  name = "rustorb-python"
500
- version = "0.2.0"
500
+ version = "0.3.0"
501
501
  dependencies = [
502
502
  "pyo3",
503
503
  "pyo3-build-config",
@@ -507,7 +507,7 @@ dependencies = [
507
507
 
508
508
  [[package]]
509
509
  name = "rustorb-typesupport"
510
- version = "0.2.0"
510
+ version = "0.3.0"
511
511
  dependencies = [
512
512
  "rustorb-cdr",
513
513
  ]
@@ -3,7 +3,7 @@ resolver = "3"
3
3
  members = ["crates/rustorb-cdr", "crates/rustorb-giop", "crates/rustorb-core", "crates/rustorb-python"]
4
4
 
5
5
  [workspace.package]
6
- version = "0.2.0"
6
+ version = "0.3.0"
7
7
  edition = "2024"
8
8
  rust-version = "1.85"
9
9
  license = "MIT OR Apache-2.0"
@@ -13,11 +13,11 @@ keywords = ["corba", "giop", "iiop", "orb", "rpc"]
13
13
  categories = ["network-programming"]
14
14
 
15
15
  [workspace.dependencies]
16
- rustorb-cdr = { path = "crates/rustorb-cdr", version = "0.2.0" }
17
- rustorb-typesupport = { path = "crates/rustorb-typesupport", version = "0.2.0" }
18
- rustorb-giop = { path = "crates/rustorb-giop", version = "0.2.0" }
19
- rustorb-core = { path = "crates/rustorb-core", version = "0.2.0" }
20
- rustorb-naming = { path = "crates/rustorb-naming", version = "0.2.0" }
16
+ rustorb-cdr = { path = "crates/rustorb-cdr", version = "0.3.0" }
17
+ rustorb-typesupport = { path = "crates/rustorb-typesupport", version = "0.3.0" }
18
+ rustorb-giop = { path = "crates/rustorb-giop", version = "0.3.0" }
19
+ rustorb-core = { path = "crates/rustorb-core", version = "0.3.0" }
20
+ rustorb-naming = { path = "crates/rustorb-naming", version = "0.3.0" }
21
21
  tokio = { version = "1", default-features = false }
22
22
 
23
23
  [workspace.lints.rust]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rustorb
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Classifier: Programming Language :: Python :: 3
5
5
  Classifier: Topic :: System :: Networking
6
6
  Classifier: Topic :: Software Development :: Object Brokering
@@ -30,6 +30,12 @@ pub struct Encoder {
30
30
  /// The valuetypes written so far (for indirections) and the chunk
31
31
  /// being written; made with the first value.
32
32
  pub(crate) values: Option<Box<crate::value::WriteState>>,
33
+ /// The 8-byte alignment points written since
34
+ /// [`track_align8`](Encoder::track_align8), each as the buffer length
35
+ /// before its padding and the padding written; `None` when not
36
+ /// tracked, or when something was written whose bytes depend on
37
+ /// stream offsets (see [`take_align8`](Encoder::take_align8)).
38
+ align8: Option<Vec<(usize, usize)>>,
33
39
  }
34
40
 
35
41
  macro_rules! write_number {
@@ -66,6 +72,7 @@ impl Encoder {
66
72
  origin: 0,
67
73
  wstring_bom: true,
68
74
  values: None,
75
+ align8: None,
69
76
  }
70
77
  }
71
78
 
@@ -96,10 +103,48 @@ impl Encoder {
96
103
  }
97
104
 
98
105
  /// The stream offset of the next byte.
106
+ ///
107
+ /// A caller that writes bytes depending on it (an offset or an
108
+ /// indirection) calls [`pin`](Encoder::pin) as well.
99
109
  pub fn position(&self) -> usize {
110
+ self.offset()
111
+ }
112
+
113
+ /// The stream offset of the next byte.
114
+ pub(crate) fn offset(&self) -> usize {
100
115
  self.base + self.len()
101
116
  }
102
117
 
118
+ /// Starts recording where the stream is aligned to 8 bytes, so that
119
+ /// the bytes written from here on can be moved by 4 bytes with
120
+ /// [`take_align8`](Encoder::take_align8). Only for GIOP encodings;
121
+ /// recording stops for good when something is written whose bytes
122
+ /// depend on stream offsets: a valuetype, a call to
123
+ /// [`pin`](Encoder::pin), [`set_origin`](Encoder::set_origin),
124
+ /// [`as_bytes_mut`](Encoder::as_bytes_mut) or
125
+ /// [`truncate`](Encoder::truncate).
126
+ pub fn track_align8(&mut self) {
127
+ self.align8 = self.encoding.is_giop().then(Vec::new);
128
+ }
129
+
130
+ /// Stops recording, and returns the 8-byte alignment points written
131
+ /// since [`track_align8`](Encoder::track_align8): each is the buffer
132
+ /// length before its padding and the length of that padding. Data
133
+ /// whose alignment is at most 4 does not depend on the stream offset
134
+ /// modulo 8, so the bytes written since can be moved by 4 bytes by
135
+ /// recomputing the padding at these points alone. `None` if not
136
+ /// recording, or if recording stopped.
137
+ pub fn take_align8(&mut self) -> Option<Vec<(usize, usize)>> {
138
+ self.align8.take()
139
+ }
140
+
141
+ /// Says that bytes written from here on depend on stream offsets, as
142
+ /// an indirection does, so the stream cannot be moved: stops
143
+ /// [`track_align8`](Encoder::track_align8) for good.
144
+ pub fn pin(&mut self) {
145
+ self.align8 = None;
146
+ }
147
+
103
148
  /// Bytes written so far, shared octets included.
104
149
  pub fn len(&self) -> usize {
105
150
  self.buf.len() + self.shared_len
@@ -120,12 +165,14 @@ impl Encoder {
120
165
  /// buffer indexes, which differ from stream offsets after shared
121
166
  /// octets.
122
167
  pub fn as_bytes_mut(&mut self) -> &mut [u8] {
168
+ self.align8 = None;
123
169
  &mut self.buf
124
170
  }
125
171
 
126
172
  /// Drops bytes past `len`, which must not be before shared octets.
127
173
  pub fn truncate(&mut self, len: usize) {
128
174
  debug_assert!(self.shared.last().is_none_or(|(at, _)| *at <= len));
175
+ self.align8 = None;
129
176
  self.buf.truncate(len);
130
177
  }
131
178
 
@@ -175,9 +222,15 @@ impl Encoder {
175
222
  /// [`set_origin`](Encoder::set_origin)).
176
223
  pub fn align(&mut self, align: usize) {
177
224
  let align = align.min(self.encoding.max_align());
178
- let rem = (self.position() - self.origin) % align;
179
- if rem != 0 {
180
- self.buf.resize(self.buf.len() + align - rem, 0);
225
+ let rem = (self.offset() - self.origin) % align;
226
+ let pad = if rem == 0 { 0 } else { align - rem };
227
+ if align == 8 {
228
+ if let Some(points) = self.align8.as_mut() {
229
+ points.push((self.buf.len(), pad));
230
+ }
231
+ }
232
+ if pad != 0 {
233
+ self.buf.resize(self.buf.len() + pad, 0);
181
234
  }
182
235
  }
183
236
 
@@ -192,7 +245,8 @@ impl Encoder {
192
245
  /// `PUSH(ORIGIN)`; the parameter headers of
193
246
  /// [`begin_parameter`](Encoder::begin_parameter) do it themselves.
194
247
  pub fn set_origin(&mut self, origin: usize) {
195
- debug_assert!(origin <= self.position());
248
+ debug_assert!(origin <= self.offset());
249
+ self.align8 = None;
196
250
  self.origin = origin;
197
251
  }
198
252
 
@@ -100,6 +100,8 @@ impl Encoder {
100
100
  ///
101
101
  /// A value nested in a chunked value is chunked as well.
102
102
  pub fn begin_value(&mut self, key: u64, ids: &[&str], chunked: bool) -> Result<bool> {
103
+ // Chunk lengths and indirections depend on stream offsets.
104
+ self.pin();
103
105
  let state = self.values.get_or_insert_with(Default::default);
104
106
  if let Some(&tag_at) = state.written.get(&key) {
105
107
  self.write_u32(INDIRECTION);
@@ -438,7 +438,7 @@ impl Encoder {
438
438
  extended,
439
439
  origin: self.origin,
440
440
  };
441
- self.origin = self.position();
441
+ self.origin = self.offset();
442
442
  Ok(mark)
443
443
  }
444
444