-
-
Notifications
You must be signed in to change notification settings - Fork 560
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(rust): enable requests to be messages
- Loading branch information
1 parent
a5c7586
commit 153a866
Showing
112 changed files
with
2,777 additions
and
1,016 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,39 @@ | ||
use ockam::Message; | ||
use ockam::{deserialize, serialize, Decodable, Encodable, Encoded, Message}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Serialize, Deserialize)] | ||
#[derive(Serialize, Deserialize, Message)] | ||
pub struct FileDescription { | ||
pub name: String, | ||
pub size: usize, | ||
} | ||
impl Message for FileDescription {} | ||
|
||
#[derive(Serialize, Deserialize)] | ||
impl Encodable for FileDescription { | ||
fn encode(self) -> ockam::Result<Encoded> { | ||
serialize(self) | ||
} | ||
} | ||
|
||
impl Decodable for FileDescription { | ||
fn decode(v: &[u8]) -> ockam::Result<Self> { | ||
deserialize(v) | ||
} | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Message)] | ||
pub enum FileData { | ||
Description(FileDescription), | ||
Data(Vec<u8>), | ||
Quit, | ||
} | ||
|
||
impl Message for FileData {} | ||
impl Encodable for FileData { | ||
fn encode(self) -> ockam::Result<Encoded> { | ||
serialize(self) | ||
} | ||
} | ||
|
||
impl Decodable for FileData { | ||
fn decode(v: &[u8]) -> ockam::Result<Self> { | ||
deserialize(v) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.