Trait TripcodeHash

Source
pub trait TripcodeHash: Sized {
    // Required methods
    fn decode(tripcode: &str) -> Option<Self>;
    fn max_len() -> usize;
    fn max_len_sjis() -> usize;
    fn append(self, _: &mut String);
    fn write<W: Write>(self, _: &mut W) -> Result<()>;
    fn decode_from_sjis(_: &[u8]) -> Option<Self>;
    fn append_sjis(self, _: &mut Vec<u8>);
    fn write_sjis<W: Write>(self, _: &mut W) -> Result<()>;

    // Provided methods
    fn encode(self) -> String { ... }
    fn encode_to_sjis(self) -> Vec<u8>  { ... }
}
Expand description

Trait for hash values that represent tripcodes.

Required Methods§

Source

fn decode(tripcode: &str) -> Option<Self>

Decodes a tripcode into a hash value.

Returns None when passed a invalid tripcode.

Source

fn max_len() -> usize

Returns maximum length of resulting tripcode, in bytes.

Source

fn max_len_sjis() -> usize

Returns maximum length of resulting tripcode when encoded in Shift-JIS, in bytes.

Source

fn append(self, _: &mut String)

Encodes self into a tripcode and appends it on a String.

Source

fn write<W: Write>(self, _: &mut W) -> Result<()>

Encodes self into a tripcode and writes it to a Write.

Source

fn decode_from_sjis(_: &[u8]) -> Option<Self>

Decodes a Shift-JIS-encoded tripcode.

Source

fn append_sjis(self, _: &mut Vec<u8>)

Encodes self into a Shift-JIS-encoded tripcode and appends it on a Vec<u8>.

Source

fn write_sjis<W: Write>(self, _: &mut W) -> Result<()>

Encodes self into a Shift-JIS-encoded tripcode and writes it to a Write.

Provided Methods§

Source

fn encode(self) -> String

Encodes self into a tripcode.

Source

fn encode_to_sjis(self) -> Vec<u8>

Encodes self into a Shift-JIS-encoded tripcode.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§