Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
Neos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Neos
Commits
68bd1aee
Commit
68bd1aee
authored
Mar 16, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add BufferWriter in rust-src
parent
d48085ca
Pipeline
#20741
failed with stages
in 8 minutes and 18 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
1 deletion
+34
-1
rust-src/src/buffer.rs
rust-src/src/buffer.rs
+33
-0
rust-src/src/lib.rs
rust-src/src/lib.rs
+1
-1
No files found.
rust-src/src/buffer.rs
View file @
68bd1aee
...
@@ -72,3 +72,36 @@ impl BufferReader {
...
@@ -72,3 +72,36 @@ impl BufferReader {
ret
ret
}
}
}
}
#[wasm_bindgen]
pub
struct
BufferWriter
{
array
:
Vec
<
u8
>
,
}
#[wasm_bindgen]
impl
BufferWriter
{
#[wasm_bindgen(constructor)]
pub
fn
new
()
->
Self
{
Self
{
array
:
Vec
::
new
()
}
}
pub
fn
writeUint8
(
&
mut
self
,
value
:
u8
)
{
self
.array
.push
(
value
);
}
pub
fn
writeInt8
(
&
mut
self
,
value
:
i8
)
{
self
.array
.extend
(
value
.to_le_bytes
());
}
pub
fn
writeUint32
(
&
mut
self
,
value
:
u32
)
{
self
.array
.extend
(
value
.to_le_bytes
());
}
pub
fn
writeInt32
(
&
mut
self
,
value
:
i32
)
{
self
.array
.extend
(
value
.to_le_bytes
());
}
pub
fn
toArray
(
self
)
->
Vec
<
u8
>
{
self
.array
}
}
rust-src/src/lib.rs
View file @
68bd1aee
...
@@ -5,7 +5,7 @@ mod buffer;
...
@@ -5,7 +5,7 @@ mod buffer;
mod
utils
;
mod
utils
;
pub
use
adapters
::
*
;
pub
use
adapters
::
*
;
pub
use
buffer
::
BufferReader
;
pub
use
buffer
::
{
BufferReader
,
BufferWriter
}
;
pub
use
utils
::
set_panic_hook
;
pub
use
utils
::
set_panic_hook
;
// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment