Skip to content

docs: update README usage section with serialize sample and blittable structs - #89

Draft
google-labs-jules[bot] wants to merge 4 commits into
mainfrom
jules-17471951661693468938-4938ae38
Draft

docs: update README usage section with serialize sample and blittable structs#89
google-labs-jules[bot] wants to merge 4 commits into
mainfrom
jules-17471951661693468938-4938ae38

Conversation

@google-labs-jules

Copy link
Copy Markdown
Contributor

Added serialize code sample to the existing code block in the Usage section of README.md and introduced a dedicated 'Blittable Structs' subsection outlining their benefits and usage.


PR created automatically by Jules for task 17471951661693468938 started by @sator-imaging

@google-labs-jules

Copy link
Copy Markdown
Contributor Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Aug 20, 2026
Comment thread README.md Outdated
Blittable structs provide significant benefits:
- **No Offset Table**: Serialized directly as raw memory payloads without field offset overhead.
- **Instant Materialization**: Convert a View directly back to the original struct using the `.Materialize()` extension method.
- **Maximum Performance**: Fast direct memory copy operations with zero deserialization overhead.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- **Maximum Performance**: Fast direct memory copy operations with zero deserialization overhead.
- **Maximum Performance**: Fast direct memory copy operations with zero serialization/deserialization overhead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied suggestion to emphasize zero serialization/deserialization overhead.

Comment thread README.md Outdated

Blittable structs provide significant benefits:
- **No Offset Table**: Serialized directly as raw memory payloads without field offset overhead.
- **Instant Materialization**: Convert a View directly back to the original struct using the `.Materialize()` extension method.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- **Instant Materialization**: Convert a View directly back to the original struct using the `.Materialize()` extension method.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied suggestion to remove redundant materialization bullet point.

Comment thread README.md Outdated

// Serializing a blittable struct (exact fixed byte size available via RequiredByteLength)
var transform = new Transform { PositionX = 1.0f, PositionY = 2.0f, PositionZ = 3.0f };
var buffer = new byte[TransformView.RequiredByteLength];

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var buffer = new byte[TransformView.RequiredByteLength];
var buffer = new byte[TransformView.RequiredByteLength]; // 12 bytes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied suggestion to add '// 12 bytes' comment to byte array allocation.

Comment thread README.md Outdated

// Serializing data into a buffer using generated 'Serialize' extension method.
var packet = new Packet { Id = 1, Name = "John", Values = new[] { 10, 20 } };
var buffer = new byte[256];

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var buffer = new byte[256];
Span<byte> buffer = stackalloc byte[256];

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied suggestion to use stackalloc byte buffer for serialization.

Comment thread README.md Outdated
Structs marked with both `[ZeroSerializer]` and `[StructLayout(LayoutKind.Sequential, Pack = 1)]` are recognized as blittable structs.

Blittable structs provide significant benefits:
- **No Offset Table**: Serialized directly as raw memory payloads without field offset overhead.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- **No Offset Table**: Serialized directly as raw memory payloads without field offset overhead.
- **No Offset Table**: Serialized directly as raw memory payloads without field offset table.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied suggestion to update wording to 'field offset table'.

Comment thread README.md Outdated

Blittable structs provide significant benefits:
- **No Offset Table**: Serialized directly as raw memory payloads without field offset overhead.
- **Maximum Performance**: Fast direct memory copy operations with zero serialization/deserialization overhead.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- **Maximum Performance**: Fast direct memory copy operations with zero serialization/deserialization overhead.
- **Maximum Performance**: Fast direct memory copy operations with zero overhead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied suggestion to simplify maximum performance description.

Comment thread README.md Outdated
Comment on lines 58 to 63
@@ -58,6 +63,35 @@ ReadOnlyMemory<byte> retainedData = packetView;
```

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed implicit conversion section as suggested.

Comment thread README.md Outdated
int writtenBytes = packet.Serialize(buffer);
```

View construction does not read every property. Values are decoded directly from the original memory only on access.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
View construction does not read every property. Values are decoded directly from the original memory only on access.
> [!TIP]
> View construction does not read every property. Values are decoded directly from the original memory only on access.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatted view construction note as a GitHub [!TIP] callout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant