{"action":"created","issue":{"url":"https://api.github.com/repos/serde-rs/serde/issues/529","repository_url":"https://api.github.com/repos/serde-rs/serde","labels_url":"https://api.github.com/repos/serde-rs/serde/issues/529/labels{/name}","comments_url":"https://api.github.com/repos/serde-rs/serde/issues/529/comments","events_url":"https://api.github.com/repos/serde-rs/serde/issues/529/events","html_url":"https://github.com/serde-rs/serde/issues/529","id":173437265,"number":529,"title":"Implementing custom type serializing","user":{"login":"Relrin","id":1627100,"avatar_url":"https://avatars.githubusercontent.com/u/1627100?v=3","gravatar_id":"","url":"https://api.github.com/users/Relrin","html_url":"https://github.com/Relrin","followers_url":"https://api.github.com/users/Relrin/followers","following_url":"https://api.github.com/users/Relrin/following{/other_user}","gists_url":"https://api.github.com/users/Relrin/gists{/gist_id}","starred_url":"https://api.github.com/users/Relrin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Relrin/subscriptions","organizations_url":"https://api.github.com/users/Relrin/orgs","repos_url":"https://api.github.com/users/Relrin/repos","events_url":"https://api.github.com/users/Relrin/events{/privacy}","received_events_url":"https://api.github.com/users/Relrin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-08-26T12:00:07Z","updated_at":"2016-08-28T17:07:50Z","closed_at":null,"body":"I'm trying to implement custom type serializer for the BigInt type. So, the first thing that I've made is a look into the [serde docs](https://serde.rs/impl-serialize.html). But this case a little bit complex, that described inside the doc.\r\n\r\nThat's a code, which I'm using for a serializing:\r\n```rust \r\nuse num::bigint::{BigInt, Sign};  // other crate\r\nuse serde::ser;\r\n\r\npub struct Serializer<W>{\r\n    writer: W\r\n}\r\n\r\nimpl<W> ser::Serializer for Serializer<W> where W: io::Write {\r\n  // some code there...\r\n}\r\n\r\nimpl ser::Serialize for BigInt {\r\n    fn serialize<S>(&self, serializer: &mut S) -> Result<()> where S: Serializer {\r\n        let (sign, bytes) = *self.to_bytes_le();\r\n        let length = bytes.len();\r\n        match length {\r\n            0...255 => self.get_small_big_number(sign, length as u8, bytes),\r\n            _ => self.get_large_big_number(sign, length as u32, bytes),\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nAs a result, the complier generates an error:\r\n```\r\nsrc/serializers.rs:591:71: 591:81 error: `Serializer` is not a trait [E0404]\r\nsrc/serializers.rs:591     fn serialize<S>(&self, serializer: &mut S) -> Result<()> where S: Serializer {\r\n                                                                                             ^~~~~~~~~~\r\nsrc/serializers.rs:591:71: 591:81 help: run `rustc --explain E0404` to see a detailed explanation\r\nerror: cannot continue compilation due to previous error\r\nerror: Could not compile `bert`.\r\n```\r\n\r\nHow can I connect all this stuff together and provide method to serialize BigInt type? I've also trying to implement serializing for BigInt type from the `num` crate as described [there](https://serde.rs/newtype-wrapper.html), but getting the same error as I said earlier."},"comment":{"url":"https://api.github.com/repos/serde-rs/serde/issues/comments/242986166","html_url":"https://github.com/serde-rs/serde/issues/529#issuecomment-242986166","issue_url":"https://api.github.com/repos/serde-rs/serde/issues/529","id":242986166,"user":{"login":"Relrin","id":1627100,"avatar_url":"https://avatars.githubusercontent.com/u/1627100?v=3","gravatar_id":"","url":"https://api.github.com/users/Relrin","html_url":"https://github.com/Relrin","followers_url":"https://api.github.com/users/Relrin/followers","following_url":"https://api.github.com/users/Relrin/following{/other_user}","gists_url":"https://api.github.com/users/Relrin/gists{/gist_id}","starred_url":"https://api.github.com/users/Relrin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Relrin/subscriptions","organizations_url":"https://api.github.com/users/Relrin/orgs","repos_url":"https://api.github.com/users/Relrin/repos","events_url":"https://api.github.com/users/Relrin/events{/privacy}","received_events_url":"https://api.github.com/users/Relrin/received_events","type":"User","site_admin":false},"created_at":"2016-08-28T17:07:50Z","updated_at":"2016-08-28T17:07:50Z","body":"@arthurprs I've tried this, but this didn't help me also:\r\n\r\n```rust\r\nsrc/serializers.rs:593:5: 603:6 error: method `serialize` has an incompatible type for trait:\r\n expected associated type,\r\n    found enum `errors::Error` [E0053]\r\nsrc/serializers.rs:593     fn serialize<S>(&self, serializer: &mut S) -> Result<()> where S: ser::Serializer\r\n                           ^\r\nsrc/serializers.rs:593:5: 603:6 help: run `rustc --explain E0053` to see a detailed explanation\r\n```"}}
{"actor":{"display_login":"Relrin"}}